6g将完成标志作为输出标志,导致“包装:无法打开”错误

Started getting a pack: cannot open error on all my go projects.

Tried to run a simple go file:

main.go:

package main

import "fmt"

func main() {
    fmt.Println("Hello, playground")
}

and got the same result:

$ go run main.go
# command-line-arguments
pack: cannot open $WORK/command-line-arguments/_obj/_go_.6

I did have a new file in the directory called mplete which seemed to be the output from the 6g compiler.

running the steps output from go run -x main.go manually I found the 6g compiler is taking the flag -complete and reading it as -o mplete. Which sets the output file to meplete

$ ls
main.go  work_tmp
$ /usr/local/go/pkg/tool/linux_amd64/6g -o $WORK/command-line-arguments/_obj/_go_.6 -p command-line-arguments -complete -D _/tmp/taco -I $WORK ./main.go
$ ls
main.go  mplete  work_tmp

Changing the -complete flag changed the file that was output:

$ ls
main.go  work_tmp
$ /usr/local/go/pkg/tool/linux_amd64/6g -o $WORK/command-line-arguments/_obj/_go_.6 -p command-line-arguments -cotaco -D _/tmp/taco -I $WORK ./main.go
$ ls
main.go  taco  work_tmp

My go evn

GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jpoz/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CGO_ENABLED="1"

Figured it out!

I had two version of go installed on my machine:

go1.0.3 in /usr/local/go and go1.1.1 in /usr/local/bin/go

which go would use go1.1.1 but since GOROOT was set to /usr/local/go the build was using the old 6g compiler!!