This is the ubuntu14.04 AMD64 to build the Go compiler environment, the use of the IDE replaced with sublime text, the specific steps are referred to http://blog.csdn.net/aqiang912/article/details/ 46775409, I will not repeat it.
On the dependency analysis, it should be a more troublesome place. Took a little time to read the syntax, found that in addition to some very different places such as the type is placed behind the variable, the others are mostly similar to C and Java, it is easy to get started.
Here is a small example of how Golang is to import a package:
First we create a folder in our own home directory test, inside Create a go file, Test.go, the content is as follows:
" FMT " func Test () { fmt. Printf ("This istest->test func\n")}
Then we need to compile this package, simple, to this directory go install or go bulid, the results are as follows:
Note that there is no setting gopath environment variable, OK, set the chant, then continue build and install
Export Gopath=~/go
The result is still an error,
And then I went to find out how this gopath was set up and found this article, http://www.jb51.net/article/56779.htm
Inside the analysis of the Gopath should have a src folder, put the source files in the inside, complete and then compile.
So I built a src folder under the ~/go folder, moved the test folder into ~/GO/SRC, and then compiled the test folder, go build test, go install test results are as follows:
Nothing shows, the compilation is successful!
Next Test, in the Go directory to create a new Hello.go file, the content is as follows:
" Test " Func Main () { test. Test ()}
Run Hello.go, go run hello.go, the results are as follows:
In this way, you have completed the process of building your own package and importing it.
Subsequent:
After I found that I modified the test.go, without recompiling the case directly run Hello.go, the contents of the content has not changed. So also need to compile again, I first use go build test, found still not changed, and then use go install test, this time, check the go build and go install instructions, found as follows:
Build is only compiled, and install will also put the compiled file into the Pkg folder, the difference between the discussion: HTTP://WWW.GOLANGTC.COM/T/549EC036421AA9396A0000C7
Private thought or more use install, after all, powerful some.
Spent a long time, to go language research, did some small work, ashamed ashamed (smiley face.
"Go" continue to go Go go,ubuntu analysis of environment construction and Golang dependence