uw-labs/substrate

SynchronousAdapter panic when using byte slice as message

Opened this issue · 1 comments

The following line causes a panic if the underlying type of the substrate.Message is a slice:

https://github.com/uw-labs/substrate/blob/master/sync_adapter_sink.go#L98-L100

panic: runtime error: comparing uncomparable type writer.message

goroutine 19 [running]:
github.com/uw-labs/substrate.(*synchronousMessageSinkAdapter).loop.func2(0x0, 0x0)
        /home/johan/go/pkg/mod/github.com/uw-labs/substrate@v0.0.0-20200325102738-bcdc00ce7555/sync_adapter_sink.go:98 +0x301
github.com/uw-labs/sync/rungroup.(*group).Go.func1(0xc00041c000, 0xc00041c060)
        /home/johan/go/pkg/mod/github.com/uw-labs/sync@v0.0.0-20190307114256-1bb306bf6e71/rungroup/rungroup.go:55 +0x59
created by github.com/uw-labs/sync/rungroup.(*group).Go
        /home/johan/go/pkg/mod/github.com/uw-labs/sync@v0.0.0-20190307114256-1bb306bf6e71/rungroup/rungroup.go:52 +0x66
exit status 2

For example, using a type like:

type message []byte

func (m message) Data() []byte {
	return []byte(m)
}

Workaround is to use a pointer to the data.