Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues installing a go program

Tags:

macos

go

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?

like image 855
Jon Avatar asked Dec 16 '25 18:12

Jon


1 Answers

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.

like image 80
Joris Avatar answered Dec 19 '25 21:12

Joris



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!