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

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

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