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
- Host: GitHub
- URL: https://github.com/iwind/gosock
- Owner: iwind
- License: bsd-3-clause
- Created: 2021-07-06T13:47:17.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-12-24T08:02:39.000Z (over 1 year ago)
- Last Synced: 2025-10-12T15:32:00.285Z (9 months ago)
- Language: Go
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)
}
~~~