You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\vbox\AppData\Local\go-build
set GOENV=C:\Users\vbox\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\vbox\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\vbox\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16.2
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\vbox\AppData\Local\Temp\go-build406273817=/tmp/go-build -gno-record-gcc-switches
However it seems that using Go it is not possible to listen to both IPv4 and IPv6 and detect port conflicts with other programs (on Windows).
The use case is quite simple:
another program is running on a certain port
start your Go program using tcp as the address, since you want to listen on all available network stacks, and using the same port as the other running program
the Go program should not start on Windows the same way it does on *NIX
Other programming languages don't have the same problem, and Go behaves differently based on the operating system.
How can I prevent my Go program from starting if another program is running on the same port? Only on Windows do I have to try the binding also on tcp4 and quit my program if it fails? I would have expected such a workaround within Go itself if it is the only way.
This looks like something that should be fixed. Thank you
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
please try the following reproducer
What did you expect to see?
On Linux and macOS I have this output:
What did you see instead?
On Windows I have this output:
The text was updated successfully, but these errors were encountered: