• Register
0 votes

Problem :

I want to install the custom package for my main.go file. But, whenever I try to run below command :

go install custom.go

I often face below error :

go install: no install location for .go files listed on command line (GOBIN not set)

How can I fix this issue ?

6 5 3
7,540 points

1 Answer

0 votes

Solution :

Please check your GOPATH variable.
Please make sure:

· Your sources should be under the GOPATH/src

· You must have the bin folder within your GOPATH folder.

The command with your source in DIR/src/foo/quux should be installed into DIR/bin/quux, not DIR/bin/foo/quux. The "foo/" prefix should be stripped so that you can add DIR/bin to your PATH to get all the installed commands.

If your GOBIN environment variable is set the commands are installed to the directory it names instead of DIR/bin. GOBIN must be the absolute path.

It appears as if your GOPATH is set to ~/go but you ran the go install command on the ~/dev/go

The Go path is the list of directory trees containing the Go source code. It is considered to resolve the imports which cannot be found in the standard Go tree.

If you have done go build correctly then you can also try a go install and you need to install the package, not a single file.

9 7 4
38,600 points
Issue in go Install

Related questions

0 votes
1 answer 2K views
Problem : I created my private repo examplessite/myprivaterepo using my Github UI from my browser. Then I went to my go directory which is on my desktop and tried to clone it: $ cd $GOPATH $ go get github.com/examplessite/myprivaterepo So far so good. I created ... .com/examplessite/myprivaterepo: exit status 128 Why is the laptop ignoring my own repo and how can I make it to accept its luck?
asked Dec 17, 2019 alecxe 7.5k points
0 votes
1 answer 657 views
Problem : Getting bellow error related to curses in python code curses is not supported on this machine (please install/reinstall curses for an optimal experience)
asked Nov 7, 2019 peterlaw 6.9k points
2 votes
2 answers 155 views
Problem: What command line utility can be used to repair the BCD on a Windows installation?
asked Mar 23 ArifulIslam 5.7k points
1 vote
1 answer 26 views
GOPATH is DIR. Created folders for src, bin and pkg under DIR. There is a package in /DIR/src/lib/ as lib.go. The GOBIN value is set to /DIR/bin. When I try to run go install lib.go from /DIR/src/lib it says the error "go install: no install ... on command line (GOBIN not set)". I listed my environment variables using "go env". Both the GOPATH and GOBIN values are set correctly. Please help
asked May 6 anonymous