GO:未知标志-trimpath

This is my first time with GO.

/* hello.go  My first GOlang program */

package main

import "fmt"

func main() {
        fmt.Printf("Hello World
")
}

I am getting this error:

# command-line-arguments

/usr/local/go/pkg/tool/darwin_amd64/6g: unknown flag -trimpath

I am not able to understand what is the problem.

Apparently, this is related to the way go has been installed.
See GOlang Some Common Errors

after trying 1.3 meant “you need to unapck your .tar.gz file to /usr/local

http://golang.org/doc/install#tarball

One can not just install the golang 1.3 from the installer, you should try out the untar option for better results.

Errors found during :

brew install spiff
go install github.com/tools/godep

# github.com/kr/fs
/usr/local/go/pkg/tool/darwin_amd64/6g: unknown flag -trimpath

So follow the install section

Download the archive and extract it into /usr/local, creating a Go tree in /usr/local/go.
For example:

tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz

Choose the archive file appropriate for your installation. For instance, if you are installing Go version 1.3 for 64-bit x86 on Linux, the archive you want is called go1.3.linux-amd64.tar.gz.

Add /usr/local/go/bin to the PATH environment variable. You can do this by adding this line to your /etc/profile (for a system-wide installation) or $HOME/.profile.

export PATH=$PATH:/usr/local/go/bin

To uninstall and start over: see Uninstall Go

To remove an existing Go installation from your system delete the go directory. This is usually /usr/local/go under Linux, Mac OS X, and FreeBSD or c:\Go under Windows.

You should also remove the Go bin directory from your PATH environment variable.
Under Linux and FreeBSD you should edit /etc/profile or $HOME/.profile. If you installed Go with the Mac OS X package then you should remove the /etc/paths.d/go file.

这个参数 -trimpath 需要 go 1.13 以上版本才能识别,作用是剔除Go编译文件的GOPATH信息!