Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: net.Listen cannot handle IPv6 addresses not wrapped in square brackets #53106

Closed
1366613 opened this issue May 27, 2022 · 1 comment
Closed

Comments

@1366613
Copy link

1366613 commented May 27, 2022

What version of Go are you using (go version)?

$ go version
go version devel go1.19-dd97871282 Thu Apr 14 18:00:13 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/user/go-linux-amd64-bootstrap/bin"
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/user/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/user/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/user/go-linux-amd64-bootstrap"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/user/go-linux-amd64-bootstrap/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.19-dd97871282 Thu Apr 14 18:00:13 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1164764538=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Listen to the address ::1
https://go.dev/play/p/RA_UpIcsvtp?v=gotip

What did you expect to see?

net.Listen being able to handle IPv6 addresses not wrapped in square brackets

What did you see instead?

error: too many colons in address

I think either net.Listen has to handle IPv6 addresses the way net.ParseIP does, or otherwise net.ParseIP has to return an error on IPv6 addresses not wrapped in square brackets.

@mdlayher
Copy link
Member

Please see https://pkg.go.dev/net#JoinHostPort which handles this case correctly. String concatenation does not work. Closing.

@golang golang locked and limited conversation to collaborators May 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants