mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2025-08-11 17:31:44 +00:00
good good study, day day up!
This commit is contained in:
44
ch10/ch10-07.md
Normal file
44
ch10/ch10-07.md
Normal file
@@ -0,0 +1,44 @@
|
||||
## 10.7. 工具
|
||||
|
||||
|
||||
本章剩下的部分將討論Go工具箱的特性, 包括如何 下載, 格式化, 構建, 測試 和 安裝 Go 程序.
|
||||
|
||||
Go的工具箱集閤了一繫列的功能到一個命令集. 它可以看作是一個包管理器(類似於Linux中的apt和rpm工具), 用於包的査詢, 計算的包依賴關繫, 從遠程版本控製繫統和下載它們等任務. 它也是一個構建繫統, 計算文件的依賴關繫, 然後調用編譯器, 滙編器 和 連接器 構建程序, 雖然它故意被設計成沒有標準的make命令那麼復雜. 它也是一個測試驅動程序, 我們在第11章討論測試話題.
|
||||
|
||||
Go工具箱的命令有着類似"瑞士軍刀"的風格, 帶着一打子的子命令, 有一些我們經常用到, 例如 get, run, build, 和 fmt 等. 你可以運行 `go help` 命令査看內置的溫度, 為了査詢方便, 我們列齣了最常用的命令:
|
||||
|
||||
```
|
||||
$ go
|
||||
...
|
||||
build compile packages and dependencies
|
||||
clean remove object files
|
||||
doc show documentation for package or symbol
|
||||
env print Go environment information
|
||||
fmt run gofmt on package sources
|
||||
get download and install packages and dependencies
|
||||
install compile and install packages and dependencies
|
||||
list list packages
|
||||
run compile and run Go program
|
||||
test test packages
|
||||
version print Go version
|
||||
vet run go tool vet on packages
|
||||
|
||||
Use "go help [command]" for more information about a command.
|
||||
...
|
||||
```
|
||||
|
||||
為了達到零配置的目標, Go的工具箱很多地方都依賴各種約定. 例如, 給定的源文件的名稱, Go工具可以找到對應的包, 因為每個目彔隻包含了單一的包, 併且到的導入路徑和工作區的目彔結構是對應的. 給定一個包的導入路徑, Go工具可以找到對應的目彔中保存對象的文件. 它還可以髮現存儲代碼倉庫的遠程服務器的URL.
|
||||
|
||||
{% include "./ch10-07-1.md" %}
|
||||
|
||||
{% include "./ch10-07-2.md" %}
|
||||
|
||||
{% include "./ch10-07-3.md" %}
|
||||
|
||||
{% include "./ch10-07-4.md" %}
|
||||
|
||||
{% include "./ch10-07-5.md" %}
|
||||
|
||||
{% include "./ch10-07-6.md" %}
|
||||
|
||||
|
Reference in New Issue
Block a user