Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GO : unknown flag -trimpath

Tags:

go

This is my first time with GO.

/* hello.go  My first GOlang program */

package main

import "fmt"

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

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.

like image 670
pg2455 Avatar asked Jul 12 '26 07:07

pg2455


1 Answers

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.

like image 193
VonC Avatar answered Jul 16 '26 10:07

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!