Very likely this is an issue with my set up, but I cannot figure out what is going on.
go version)?$ go version go version go1.12.9 darwin/amd64
Not sure about the tip, go1.12.9 is the latest available release on Homebrew for macOS.
go env)?go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ahmetb/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/ahmetb/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/ahmetb/.homebrew/Cellar/go/1.12.9/libexec"
GOTMPDIR=""
GOTOOLDIR="/Users/ahmetb/.homebrew/Cellar/go/1.12.9/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/ahmetb/workspace/run-latencies/cmd/probe/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/h7/n46zg3md4l57vzsgxcs355hw00dl55/T/go-build623969830=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOPATH unset, have a very simple program:
$ tree
.
├── go.mod
└── main.go
rm -rf ~/go/bin/probe
go build -o ~/go/bin/probe .
stat ~/go/bin/probe
Observe the executable file is 0644/-rw-r--r--.
I don't think my shell somehow magically got some umask that's causing files to be marked as non-executable.
The file created from go build -o should have +x bits set.
The resulting file from go build -o executable file is 0644/-rw-r--r--.
Weird enough the resulting file is actually not executable even after chmod +xing.
It seems like the binary is treated as a script:
/Users/ahmetb/go/bin/probe: line 1: syntax error near unexpected token `newline'
/Users/ahmetb/go/bin/probe: line 1: `!<arch>'

Looks like I'm an idiot, my package name was not main.
Also not sure why go install works when package name is not main.
Really glad I found this post, just helped me and a buddy out :)
me also VERY glad i found this)
Most helpful comment
Looks like I'm an idiot, my package name was not
main.Also not sure why
go installworks when package name is notmain.