<p align="right">2021年08月31日 13:54:49</p>
[TOC]
### go命令
```
? help go
go
Tool for managing go source code.
More information: https://golang.org.
- Download and install a package, specified by its import path:
go get package_path
- Compile and run a source file (it has to contain a main package):
go run file.go
- Compile a source file into a named executable:
go build -o executable file.go
- Compile the package present in the current directory:
go build
- Execute all test cases of the current package (files have to end with _test.go):
go test
- Compile and install the current package:
go install
- Initialize a new module in the current directory:
go mod init module_name
```
### 說明
```
go env用于打印Go語言的環境信息。
go run命令可以編譯并運行命令源碼文件。
go get可以根據要求和實際情況從互聯網上下載或更新指定的代碼包及其依賴包,并對它們進行編譯和安裝。
go build命令用于編譯我們指定的源碼文件或代碼包以及它們的依賴包。
go install用于編譯并安裝指定的代碼包及它們的依賴包。
go clean命令會刪除掉執行其它命令時產生的一些文件和目錄。
go doc命令可以打印附于Go語言程序實體上的文檔。我們可以通過把程序實體的標識符作為該命令的參數來達到查看其文檔的目的。
go test命令用于對Go語言編寫的程序進行測試。
go list命令的作用是列出指定的代碼包的信息。
go fix會把指定代碼包的所有Go語言源碼文件中的舊版本代碼修正為新版本的代碼。
go vet是一個用于檢查Go語言源碼中靜態錯誤的簡單工具。
go tool pprof命令來交互式的訪問概要文件的內容。
```