Go install not working properly... Any ideas?

when I run go install it creates the application in: /c/Users/backend/Documents/goworkspace/bin/test.exe

when I type test in GitBash nothing happens…

So i did echo $PATH and i get:

/c/Users/backend/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/backend/bin:/c/Python39/Scripts:/c/Python39:/c/Python38/Scripts:/c/Python38:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files/Java/jdk-13.0.2/bin:/c/Program Files/MongoDb/Server/4.0/bin:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/Yarn/bin:/cmd:/c/Program Files/nodejs:/c/Program Files/Go/bin:/c/Users/backend/AppData/Local/Microsoft/WindowsApps:/c/Users/backend/AppData/Local/Programs/Microsoft VS Code/bin:/c/Users/backend/AppData/Local/GitHubDesktop/bin:/c/Users/backend/Documents/goworkspace/bin:/c/Users/backend/go/bin:/usr/bin/vendor_perl:/usr/bin/core_perl

Which makes no sense to me because it is storing it in:

/c/Users/backend/Documents/goworkspace/bin/test.exe When I run go install.

Here is my go env :

  1. set GO111MODULE=
  2. set GOARCH=amd64
  3. set GOBIN=C:\Users\backend\Documents\goworkspace\bin
  4. set GOCACHE=C:\Users\backend\AppData\Local\go-build
  5. set GOENV=C:\Users\backend\AppData\Roaming\go\env
  6. set GOEXE=.exe
  8. set GOFLAGS=
  9. set GOHOSTARCH=amd64
  10. set GOHOSTOS=windows
  11. set GOINSECURE=
  12. set GOMODCACHE=C:\Users\backend\Documents\goworkspace\pkg\mod
  13. set GONOPROXY=
  14. set GONOSUMDB=
  15. set GOOS=windows
  16. set GOPATH=C:\Users\backend\Documents\goworkspace
  17. set GOPRIVATE=
  18. set GOPROXY=https://proxy.golang.org,direct
  19. set GOROOT=C:\Program Files\Go
  20. set GOSUMDB=sum.golang.org
  21. set GOTMPDIR=
  22. set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
  23. set GOVCS=
  24. set GOVERSION=go1.17.5
  25. set GCCGO=gccgo
  26. set AR=ar
  27. set CC=gcc
  28. set CXX=g++
  29. set CGO_ENABLED=1
  30. set GOMOD=C:\Users\backend\go.mod
  31. set CGO_CFLAGS=-g -O2
  32. set CGO_CPPFLAGS=
  33. set CGO_CXXFLAGS=-g -O2
  34. set CGO_FFLAGS=-g -O2
  35. set CGO_LDFLAGS=-g -O2
  36. set PKG_CONFIG=pkg-config
  37. set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\backend\AppData\Local\Temp\go-build3318698682=/tmp/go-build -gno-record-gcc-switche

Hi @Colton,

All path settings look correct. And you wrote that test.exe does get created.

Do you perhaps have another test.exe somewhere in your $PATH? (Unix systems do include a test command, maybe GitBash has it also…)

Does the binary run fine if you give it a different name?


As Christof is saying, POSIX defines that there is a test command.

You can check using which test or which -a test, the first one will probably show you the test from a git bash location or “built-in” hints, the latter will show you the go program as well, but not at the first position.

It’s probably easier to not name your program test.


Thank you!

Just a quick 10 cents/food for thought. When I read your setup I thought I’d just through a quick tip out to consider simplifying things and just use WSL2 instead of gitbash/cygwin style setup. It’s great to have normal Ubuntu behavior and not mix linux/windows paths and such. I feel that gitbash/cygwin were great for their time if forced to use windows if you came from Linux, but they can add more confusing issues when dealing with paths/environment stuff like this. I use macOS at work for last 2 years, but love using WSL2 with Ubuntu 20.04 on my home system). Good luck regardless.

Awesome thank you for the insight. I will check into this!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.