Skip to content

net: document @-prefix support for Unix socket addresses #78615

@nussjustin

Description

@nussjustin

Go version

go version go1.26.0 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/justinn/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/justinn/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2382649238=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/justinn/Workspace/go-playground/unixsockettest/go.mod'
GOMODCACHE='/home/justinn/.gopath/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/justinn/.gopath'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/justinn/.gopath/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.0.linux-amd64'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/home/justinn/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='go1.25.0+auto'
GOTOOLDIR='/home/justinn/.gopath/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.0.linux-amd64/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26.0'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Wrote a program that listens on a Unix socket in the abstract socket namespace using the @<name> address syntax.

Example:

conn, err := net.ListenUnixgram("unixgram", &net.UnixAddr{Name: "@test"})

What did you see happen?

No documentation on Go supporting the non-standard @<name> syntax for connecting to and listening on an abstract socket address.

An Unix socket address starting with a null-byte ('\0') is interpreted as an abstract socket address, but Go also supports using an at-symbol ('@') instead.

While it can be assumed that Go supports using the standard format using a null-byte (as that is handled by the OS itself, at least under Linux) it is not obvious that the at-symbol can be used instead.

I found some information on the web about Go supporting this and also remembered it faintly from past experiences using the @<name> syntax, but there seems to be no official documentation.

What did you expect to see?

Documentation on the supported syntax.

The handling of the at-symbol is implemented in the syscall package, but given that users generally use high-level functions and methods in the net package and not the low-level functions in the syscall package it probably makes more sense to document it in the net package.

It may also make sense to document that the null-byte variant also works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions