https://github.com/orisano/uds
unix domain socket utilities for Go
https://github.com/orisano/uds
Last synced: about 1 year ago
JSON representation
unix domain socket utilities for Go
- Host: GitHub
- URL: https://github.com/orisano/uds
- Owner: orisano
- License: mit
- Created: 2017-12-10T09:21:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-01-30T10:56:09.000Z (over 5 years ago)
- Last Synced: 2025-05-07T20:06:38.441Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# uds
unix domain socket utilities for Go.
## How to Use
examples/server/main.go
```go
package main
import (
"io"
"log"
"net/http"
"os"
"github.com/orisano/uds"
)
const (
sockPath = "./sample.sock"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "
It works!
")
})
os.Remove(sockPath)
log.Fatal(uds.ListenAndServe(sockPath, nil))
}
```
examples/client/main.go
```go
package main
import (
"io"
"log"
"os"
"github.com/orisano/uds"
)
const (
sockPath = "../server/sample.sock"
)
func main() {
client := uds.NewClient(sockPath)
resp, err := client.Get("http://unix/")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
}
```
## Author
Nao Yonashiro (@orisano)
## LICENSE
MIT