an introduction
1. Used to compile source code files or code packages.
2. Compiling non-command source files will not produce any result files.
3. Compiling the command source file will generate an executable file in the execution directory of the command.
4. When executing this command without appending any parameters, it will try to compile the current directory as a code package.
5. When this command is executed with the import path of the code package as a parameter, the code package and its dependencies will be compiled.
After adding the -a flag, all involved code packages will be recompiled.
Without the -a flag, only the archive is not the latest code package to be compiled.
6. When this command is executed with several source files as parameters, only these files will be compiled.
Two actual combat
[root@localhost ds]# ls
showds.go
[root@localhost ds]# go build showds.go
[root@localhost ds]# ls
showds showds.go
[root@localhost ds]#./showds
/root/goc2p/src/helper/ds:
showds.go
showds
[root@localhost ds]# go run showds.go
/root/goc2p/src/helper/ds:
showds.go
showds
[root@localhost ds]# cd ../../pkgtool/
[root@localhost pkgtool]# pwd
/root/goc2p/src/pkgtool
[root@localhost pkgtool]# go build
[root@localhost pkgtool]# ls
envir.go envir_test.go fpath.go ipath.go pnode.go util.go util_test.go