Weird GOBIN Bug on Windows

I’ve found a weird GOBIN bug on Windows. It’s stripping out the backslashes in the path and I don’t know how to stop it.

set GOBIN=C:UsersamunnellyTECHGobin
set GOPATH=C:\Users\amunnelly\TECH\Go

I’ve uninstalled and reinstalled Go. I’ve set a GOBIN environment variable, and I’ve tried setting GOBIN with double backslashes. Nothing doing. This is the full result of go env

set GO111MODULE=
set GOARCH=amd64
set GOBIN=C:UsersamunnellyTECHGobin
set GOCACHE=C:\Users\amunnelly\AppData\Local\go-build
set GOENV=C:\Users\amunnelly\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\amunnelly\TECH\Go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\AMUNNE~1\AppData\Local\Temp\go-build046813146=/tmp/go-build -gno-record-gcc-switches

Any thoughts or advice most gratefully accepted.

Danish version of Windows XP.

Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Eric>go.exe version
go version go1.10 windows/386

C:\Documents and Settings\Eric>go.exe env
set GOARCH=386
set GOBIN=
set GOCACHE=C:\Documents and Settings\Eric\Application Data\go-build
set GOEXE=.exe
set GOHOSTARCH=386
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Documents and Settings\Eric\go
set GORACE=
set GOROOT=C:\Programmer\go
set GOTMPDIR=
set GOTOOLDIR=C:\Programmer\go\pkg\tool\windows_386
set GCCGO=gccgo
set GO386=sse2
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
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=-m32 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\DOCUME~1\
Eric\LOKALE~1\Temp\go-build185933422=/tmp/go-build

C:\Documents and Settings\Eric>

Are you running the Windows console or a Un*x shell?

How was the variable set, a .bat file, shell script, or via the command-line?

C:\>go.exe env GOBIN


C:\>TREE "%USERPROFILE%"\go /F
Mappetræ
Diskenhedens serienummer er C804-10A1
C:\DOCUMENTS AND SETTINGS\ERIC\GO
├───bin
└───src
    └───hello
            hello.go


C:\>TYPE "%USERPROFILE%"\go\src\hello\hello.go
package main

import "fmt"

func main() {
        fmt.Printf("hello, world\n")
}

C:\>go.exe install hello

C:\>TREE "%USERPROFILE%"\go /F
Mappetræ
Diskenhedens serienummer er C804-10A1
C:\DOCUMENTS AND SETTINGS\ERIC\GO
├───bin
│       hello.exe
│
└───src
    └───hello
            hello.go


C:\>

The following evidently is successful.

C:\>DEL "%USERPROFILE%"\go\bin\hello.exe

C:\>go.exe env GOBIN


C:\>MKDIR gocode\bin

C:\>SET GOBIN=C:\gocode\bin

C:\>go.exe env GOBIN
C:\gocode\bin

C:\>go.exe install hello

C:\>TREE C:\gocode /F
Mappetræ
Diskenhedens serienummer er C804-10A1
C:\GOCODE
└───bin
        hello.exe


C:\>

Thanks for getting back to me Eric. I think you might have spotted the issue. I’ve been running my code in the Visual Studio Code editor, which has a bash terminal. I never explicitly set a GOBIN variable, but it may have been set by some process running in that VS Code bash terminal.

I’m going to think about this some more. The whole reason I was changing back and forth was that I was trying to use Go modules but it seems there’s some conflict between programs that exist along the go path and those that can use this go modules dependency tracking. I might be better served by reading those docs a little more carefully instead of bashing about and hoping things come right in the end.

Thanks again for helping me out.

Integrated Terminal (Visual Studio Code)

Windows versions

os: output CR LF for \n on Windows #28822 (Closed)

line endings, unicode, BOM

Git for Windows (legacy)