1.4 Go命令
阿新 • • 發佈:2021-07-22
如果機器上已經安裝了go,可以通過go
命令查詢go的命令
$ go Go is a tool for managing Go source code. Usage: go <command> [arguments] The commands are: bug start a bug report build compile packages and dependencies clean remove object files and cached files doc show documentation for package or symbol env print Go environment information fix update packages to use new APIs fmt gofmt (reformat) package sources generate generate Go files by processing source get add dependencies to current module and install them install compile and install packages and dependencies list list packages or modules mod module maintenance run compile and run Go program test test packages tool run specified go tool version print Go version vet report likely mistakes in packages Use "go help <command>" for more information about a command. Additional help topics: buildmode build modes c calling between Go and C cache build and test caching environment environment variables filetype file types go.mod the go.mod file gopath GOPATH environment variable gopath-get legacy GOPATH go get goproxy module proxy protocol importpath import path syntax modules modules, module versions, and more module-get module-aware go get module-auth module authentication using go.sum module-private module configuration for non-public modules packages package lists and patterns testflag testing flags testfunc testing functions Use "go help <topic>" for more information about that topic.
- go env 用於列印 Go 語言的環境資訊。
- go run 命令可以編譯並執行命令原始碼檔案。
3.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 命令來互動式的訪問概要檔案的內容。