type RPC interface {
Write([]byte) error
Read() (byte[], error)
}
Implement a struct tcpClient which implements the RPC interface.
Some boilerplate code:
type tcpClient struct {
// state of the tcp client
}
func NewClient(<some config parameters>) RPC {
// instantiate a new client
}
func (client *tcpClient) Read() ([]byte, error) {
// read the data from the end point
}
func (client *tcpClient) Write(b []byte) error {
// write the data to the end point
}
Create an interface RPC:
Implement a struct
tcpClient
which implements the RPC interface.Some boilerplate code:
Refer to these links: https://gist.github.com/adeekshith/34c20eb45bebe41f5247 https://www.linode.com/docs/guides/developing-udp-and-tcp-clients-and-servers-in-go/