This is a creation in Article, where the information may have evolved or changed.
Read the knowledge of go for a period of time, originally was directed at it is the system level language to go, at the same time have Java's appearance. After looking at this for a long time, I found this language is very good, the grammar is concise, has C's heredity. On the object-oriented, there is a bit of Java style. When it comes to writing the web, this style is so much like the Nodejs.
----------------------------------------------------------------
Well, let's start with the basics.
When the go language set environment variables, there is a very tangled thing: Gopath.
Gopath was the path to the project, and I felt it was too tangled at the beginning. If you switch the project path every time, do not set the environment variable. There's nothing to do with that. Always use idea to write go, today written, ready to compile, only to start looking at the problem again.
First put the environment variable memo:
Goroot=/usr/share/gopath=/usr/bin/go: $PATH
In fact, in the environment variable configuration, you do not need to set Gopath.
Raise a chestnut, start from scratch, and build a catalogue.
CD ~mkdir myprocexport gopath=~/myproc
In this way, the MyProc is currently set to the project path. After the go get to the thing, it is in this directory.
MyProc to follow the structure, the following sub-three directories: Bin,src,pkg.
Here's an example directory layout:
Gopath=/home/user/gocode
/home/user/gocode/
src/
foo/
bar/(go code in package bar)
X.go
quux/(go code in package main)
Y.go
bin/
Quux (Installed command)
pkg/
linux_amd64/
foo/
BAR.A (Installed package object)
That's what the authorities say about these structures.
SRC put the source code, after writing, go build a bit better.