Package netgob is a replacement for Go's gob package that also supports encoding/decoding of channels. Package netgob can be used to marshal channels in networking scenarios; the netchan library uses netgob for this purpose.
This is accomplished through the use of the new NetgobEncoder
and NetgobDecoder
interfaces. When netgob sees a channel during encoding/decoding it calls one of these interfaces. A marshaling layer can implement these interfaces to convert channels to marshaling references and vice-versa.
The same technique could be used to encode/decode functions, although netgob does not support them at this time.
To use netgob simply:
import (
"github.com/billziss-gh/netgob/gob"
)