- Security with Go
- John Daniel Leon
- 275字
- 2021-06-30 19:06:42
Installing the executable file
The go build tool is good for generating an executable file in your current working directory, but there is a way to build and install your applications so that the executables are all collected in the same location.
When you run go install it puts the output file in a default location of $GOPATH/bin. In our case, we set $GOPATH equal to our $HOME. So the default bin directory would be $HOME/bin.
You can override the location by setting the GOBIN environment variable if you want it to install somewhere else. To install our hello program, we will run the following command:
go install hello
This will build and create an executable file, ~/bin/hello. The bin directory will get created automatically if it does not already exist. If you run the install command multiple times, it will rebuild and overwrite the executable in the bin directory. Then the application can be run with this:
~/bin/hello
You can add ~/bin to your PATH environment variable for convenience. Doing so will allow you to run the applications from any working directory. To add the bin directory to your PATH, run this in the Terminal:
echo "export PATH=$PATH:$HOME/gospace/bin" >> ~/.bashrc
Be sure to restart your Terminal after that to refresh the environment variables. After that you can run the hello application by simply typing the following into the Terminal:
hello
Installing the application is completely optional. You don't have to install programs to run or build them. You can always build and run from your current working directory when developing, but it can be convenient to install finished applications that get used.
- 卓越的課件如何做(數(shù)學(xué)篇)
- 圖解博弈論
- GMAT批判性推理:邏輯分類精講
- 妙趣橫生博弈論:事業(yè)與人生的成功之道(白金版)
- 粗糙集的論域擴展理論及在專家系統(tǒng)中的應(yīng)用
- 幾何之美
- 排序問題的數(shù)學(xué)規(guī)劃松弛方法
- 代數(shù)的歷史:人類對未知量的不舍追蹤(修訂版)
- 現(xiàn)代啟發(fā)式優(yōu)化方法及其應(yīng)用
- 基于ANSYS的信號和電源完整性設(shè)計與分析(第2版)
- 歐幾里得之窗
- 幾何和統(tǒng)計(全彩版)
- Improving your C# Skills
- 二十世紀數(shù)學(xué)哲學(xué):一個自然主義者的評述
- 2019年管理類專業(yè)學(xué)位聯(lián)考綜合能力考試數(shù)學(xué)精選500題(20套全真試卷及詳解)