https://github.com/kilemonn/go-ipc
An inter-process communication library written in Golang.
https://github.com/kilemonn/go-ipc
go golang inter-process-communication linux socket unix-socket windows
Last synced: 3 months ago
JSON representation
An inter-process communication library written in Golang.
- Host: GitHub
- URL: https://github.com/kilemonn/go-ipc
- Owner: Kilemonn
- License: apache-2.0
- Created: 2024-11-02T11:30:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-11T13:39:59.000Z (over 1 year ago)
- Last Synced: 2025-02-11T14:38:07.173Z (over 1 year ago)
- Topics: go, golang, inter-process-communication, linux, socket, unix-socket, windows
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-ipc
[](https://goreportcard.com/report/github.com/Kilemonn/go-ipc)
[](https://raw.githack.com/wiki/Kilemonn/go-ipc/coverage.html)
An inter-process communication library written in Golang. Using "unix" sockets to support interprocess communication. **This also works on Windows!**
## Get started
You can add this project as a dependency using:
> go get github.com/Kilemonn/go-ipc
Once added you can setup connections as per below (error handling removed for brevity):
```go
package main
import (
"time"
"github.com/Kilemonn/go-ipc/client"
"github.com/Kilemonn/go-ipc/server"
)
func main() {
ipcChannelName := "/tmp/readme-example.sock"
svr, _ := server.NewIPCServer(ipcChannelName, nil)
defer svr.Close()
client, err := client.NewIPCClient(ipcChannelName)
defer client.Close()
accepted, err := svr.Accept(time.Millisecond * 1000)
defer accepted.Close()
content := "some-data"
n, err := client.Write([]byte(content))
b := make([]byte, len(content))
n, err = accepted.Read(b)
if content == string(b) {
fmt.Println("Sent and read is the same!")
}
}
```
## Notes
- The `IPCClient` implements the `io.ReadWriterCloser` interface and provides a property to set read timeouts instead of remaining blocking.
- This is aimed to be a very primative and simple implementation for now, other settings and customisability can be built upon what is currently implemented. However feel free to request any features that would be useful.