Go version

go1.24.5 windows/amd64

Output of go env in your module/workspace:

*(pathnames slightly redacted)*

set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=0
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\MyUser\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\MyUser\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\MyUser\AppData\Local\Temp\go-build3111314214=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=D:\Stuff\Thingy\go.mod
set GOMODCACHE=C:\Users\MyUser\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\MyUser\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\MyUser\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.24.5
set GOWORK=
set PKG_CONFIG=pkg-config

What did you do?

Ran a go test using -o for a directory:

go test -o ..\GoTests\ .\stringutils\

What did you see happen?

Upon first run after having made changes, the test executable runs from within my standard temp directory, not from within the directory that I specified using -o.

Upon further runs (until the next time changes have been made), the test executable runs from within the directory that I specified using -o.

What did you expect to see?

The test executable should always run from within the directory that I specified using -o.

EXPLANATION OF WHY I NOTICED THIS AND WHY IT MATTERS TO ME:

My antivirus program seems to be detecting any Go test executable as malware. With the default location, I can't effectively whitelist them, as they are created within a randomized directory (like %APP_DATA%\Local\Temp\go-build13853487).

I thought that -o would let me get around this, since I could make a blanket whitelist entry for all things within the directory I specified. This does help, as every time I run it other than the first time after having made changes, it runs from the directory I specified. But every single time I first run tests after having made some sort of change, my antivirus complains.

Incidentally, when this happens, go test reports "ok", even if I introduce intentional errors in the test cases. I assume this is due to the antivirus having prevented the executable from running, and "go test" thus having seen zero test failures. Seems dangerously misleading, but I guess that's an issue for another bug report.

Comment From: gabyhelp

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)