這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。
1. 安裝mercurial
Mercurial 是一種輕量級分布式版本控制系統,採用 Python 語言實現
可以輸入hg命令查詢系統是否安裝mercurial,可以如下兩種命令安裝
$sudo pip install mercurial
安裝成功之後
$sudo easy-install mercurial
安裝之後,輸入hg命令,如下內容顯示,表示成功安裝 mercuria
$ hg
Mercurial Distributed SCM
basic commands:
add add the specified files on the next commit
annotate show changeset information by line for each file
clone make a copy of an existing repository
commit commit the specified files or all outstanding changes
diff diff repository (or selected files)
export dump the header and diffs for one or more changesets
forget forget the specified files on the next commit
init create a new repository in the given directory
log show revision history of entire repository or files
merge merge working directory with another revision
pull pull changes from the specified source
push push changes to the specified destination
remove remove the specified files on the next commit
serve start stand-alone webserver
status show changed files in the working directory
summary summarize working directory state
update update working directory (or switch revisions)
use "hg help" for the full list of commands or "hg -v" for details
如上命令安裝失敗,可以直接去下載安裝
2. 擷取go原始碼
$hg clone -r release https://go.googlecode.com/hg/ go
warning: go.googlecode.com certificate with fingerprint 3f:8a:ae:12:fc:c2:65:d0:64:42:ee:6f:cc:b3:41:a1:9a:76:6e:8c not verified (check hostfingerprints or web.cacerts config setting)
adding changesets
adding manifests
adding file changes
added 19559 changesets with 68116 changes to 8835 files
updating to branch release-branch.go1.3
4167 files updated, 0 files merged, 0 files removed, 0 files unresolved
會在當前路徑建立go目錄
3.安裝go
進入 go源碼(go/src)目錄進行安裝,執行如下命令
$ ./all.bash
最後會顯示出如下內容
ALL TESTS PASSED
---
Installed Go for darwin/amd64 in /Users/angel/iProject/go
Installed commands in /Users/angel/iProject/go/bin
*** You need to add /Users/angel/iProject/go/bin to your PATH.
4.編寫HelloWorld
$ cat helloworld.go
package main
import (
"fmt"
)
func main(){
fmt.Println("Hello World")
}
5.運行程式
$ go run helloworld.go
Hello World
參考 連結