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?
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
set GOCACHE=C:\Users\Haoqing Chen\AppData\Local\go-build
set GOENV=C:\Users\Haoqing Chen\AppData\Roaming\go\env
set GOMODCACHE=C:\Users\Haoqing Chen\go\pkg\mod
set GOPATH=C:\Users\Haoqing Chen\go
set GOROOT=C:\Users\Haoqing Chen\scoop\apps\go\current
set GOTOOLDIR=C:\Users\Haoqing Chen\scoop\apps\go\current\pkg\tool\windows_amd64
set CGO_CFLAGS=-g -O3 -march=native -flto=thin
set CGO_CXXFLAGS=-g -O3 -march=native -flto=thin
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-g -O3 -march=native -flto=thin
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\HAOQIN~1\AppData\Local\Temp\go-build2509538014=/tmp/go-build -gno-record-gcc-switches
What did you do?
Tried to compile any go program and specify an executable name by -o option, such as go build -o hello ./hello-world.go
What did you expect to see?
The executable name should be hello.exe. clang and gcc both add the .exe suffix automatically.
What did you see instead?
The executable name is simply hello, which will not be recognized by Windows as an executable file.
The text was updated successfully, but these errors were encountered:
I think automagically appending file suffix in this case would not be ideal. I personally, would prefer to see the -o option output exactly what I provide it without having to account for arbitrary OS specific extension differences in behaviour. I think it's easy enough to just provide -o blah.exe as suggested by bcmills if you're working on Windows.
Yes, this looks like it's working as documented. The -o flag names a file, not a basename of the file.
Is there some reason you cannot pass -o hello.exe when compiling on Windows?
Well, I personally feels a bit awkward to write separate Makefile targets for Windows and Unix-like systems that outputs a binary to a specific path. I feel like if clang and gcc does it on Windows, it is odd to not have the same behavior for go. After all, having an executable that does not have an .exe suffix on Windows is pointless.