Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My go binaries end up in the src folder

Tags:

My binaries end up in the src folder and I have no idea why. I want them to end up in gopath/bin (since that is the default? and since I don't want binaries on git). The packages end up in gopath/pkg with their binaries in their respective folder. I don't even know if this folder structure is considered good.

Gopath is set to the gopath folder on the D:\ drive, and gobin is not set.

go setup

like image 807
Filip Haglund Avatar asked Aug 05 '14 11:08

Filip Haglund


People also ask

Where are go binaries stored?

It should be in $GOPATH/src/yourpath - using symlinks here is very useful.

Where does go build output?

go build builds the command and leaves the result in the current working directory. go install builds the command in a temporary directory then moves it to $GOPATH/bin .

How do I know if I have Gopath?

The GOPATH environment variable It defaults to a directory named go inside your home directory, so $HOME/go on Unix, $home/go on Plan 9, and %USERPROFILE%\go (usually C:\Users\YourName\go ) on Windows. If you would like to work in a different location, you will need to set GOPATH to the path to that directory.

How do you run after go install?

Add the Go install directory to your system's shell path. That way, you'll be able to run your program's executable without specifying where the executable is. Once you've updated the shell path, run the go install command to compile and install the package. Run your application by simply typing its name.


2 Answers

If you can pass a command line parameter to LiteIDE's go build instruction, you can do something like this;

go build -o $GOPATH/bin/outputfile.exe source.go

like image 70
Hiranya Avatar answered Oct 21 '22 08:10

Hiranya


As you can see in the liteIDE FAQ:

<action id="BuildAndRun" img="blue/buildrun.png" key="Ctrl+R;Ctrl+F7" task="Build;Run"/> <action id="Install" menu="Build" img="blue/install.png" key="Ctrl+F8" cmd="$(GO)" args="install $(INSTALLARGS)" save="all" output="true"/>

  • Build And Run is a go build.
  • Install is go install

Only the latter would build your exe in GOPATH/bin.

like image 28
VonC Avatar answered Oct 21 '22 08:10

VonC