Jon
Jon

Reputation: 33

Issues installing a go program

Im new to go and I have been unable to find any thing online for my issue.

I have downloaded this code https://github.com/hashicorp/http-echo and I would like to set it up so I can run this command.

$ http-echo -listen=:8080 -text="hello world"

I have been getting quite a few different path issues. Currently I have the code sitting in this directory.

/Users/jon/go/src/github.com/hashicorp

When I try and install it I get this error

$ go install http-echo
can't load package: /usr/local/go/src/http-echo/handlers.go:9:2: non-standard import "github.com/hashicorp/http-echo/version" in standard package "http-echo"

Where should I keep go projects on an OSX computer, and how do I get this to install or compile?

Upvotes: 3

Views: 135

Answers (1)

Joris
Joris

Reputation: 881

The code currently seems to be in /usr/local/go/src/http-echo. Packages should always reside in the directory $GOPATH/src/package-name, e.g.: $GOPATH/src/github.com/hashicorp/http-echo. (unless you're using go modules).

It should work if you move the source to the correct path (/Users/jon/go/src/github.com/hashicorp/http-echo). Then execute:

go install github.com/hashicorp/http-echo

Even easier would be to use go get to download the package in the first place. Simply run the following command from any directory:

go get github.com/hashicorp/http-echo

And http-echo is automagically installed.

If you still get an error after this, make sure $GOPATH/bin is in your $PATH.

Upvotes: 3

Related Questions