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

https://github.com/karpeleslab/unixconn

UnixConn tools & utils
https://github.com/karpeleslab/unixconn

Last synced: 12 months ago
JSON representation

UnixConn tools & utils

Awesome Lists containing this project

README

          

[![GoDoc](https://godoc.org/github.com/KarpelesLab/unixconn?status.svg)](https://godoc.org/github.com/KarpelesLab/unixconn)

# UnixConn tools

Some stuff commonly used made more simple.

## socketpair

Calling

```go
pair, err := unixconn.Pair()
```

Allows pair to contain two `*net.UnixConn` that are connected to each other.
Those can be used as replacement to TCP connections in test code, for example.

## cred

Golang already makes this easier thanks to `GetsockoptUcred` but I feel this
can be even better.

```go
uid, gid, pid, err := unixconn.Cred(c)
```

**NOTE**: Using `unixconn.Cred()` on a connection generated by
`unixconn.Pair()` will return the information at the time the call to Pair()
happened, and may not reflect the right information if for example the socket
was passed to a child process.