An open API service indexing awesome lists of open source software.

https://github.com/iwind/gosock

Send json command through sock in golang
https://github.com/iwind/gosock

Last synced: 6 months ago
JSON representation

Send json command through sock in golang

Awesome Lists containing this project

README

          

# gosock
Send json command through sock in golang

# Server
~~~go
var sock = NewSock("test.sock")
sock.OnCommand(func(cmd *Command) {
log.Println(cmd)
_ = cmd.ReplyOk()
})
err := sock.Listen()
if err != nil {
log.Fatal(err)
}
~~~

# Client
~~~go
var sock = NewSock("test.sock")
_, err := sock.Send(&Command{
Code: "stop",
Params: map[string]interface{}{},
})
if err != nil {
log.Fatal(err)
}
~~~