This is a creation in Article, where the information may have evolved or changed. 
Reprint: http://c2pblog.sinaapp.com/archives/355
 
 
 
Simply talk about the compilation run of the Go language.
 
Golang and C + + are compiled languages, first of all to write the source file, then compile, and finally run. These days in the use of the IDE has always been a key to run, there is no good understanding of the differences between compilation and running. And there are a few small problems in Linux that have to rethink the difference. Although the Golang compile speed, but we actually use the time must be to use the executable file, you give me a source code is meaningless, and in the actual project, your code will run on many machines, every minute will run many times, And then if you're wasting time at compile time, it's going to cost a lot. So we have to do some of the corresponding processing, the Golang source files are compiled into an executable file, and then directly in use when the implementation of the good.
 
There are two commands: Go build xxx.go and go run xxx.go
 
go build compiles the source code into an executable file, with the source file stripped of the  .go suffix, and the go run one step and compiles directly. When using go build, if this file requires external parameters, we do not need to take the parameters to compile, as long as the source file itself is good, but use go run to pay attention to have no parameters, and in conjunction with the previous blog discussed the method to do the corresponding processing. When using go run, if there are errors will be error, no error will generally run directly out of the results, using go build error will be errors, but the successful compilation will not be prompted. Run compiled files need to use  ./XXX   Such format, that is, dot + slash + filename + parameters [if any], this time to note that the runtime is not to add a suffix. Go. Generally running compiled files can be very fast. 
 
Simply put, if you do not want your source code to be seen by others, you can only provide executable files, as well as related usage methods, no need to provide source files. It's just that you have to do all the testing on your own before you commit the code, and there's an unnecessary hassle.