這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。
1. 平台 Windows, 安裝 git
2. 安裝 go 1.3+
3. 查看 GOPATH 資訊
C:\>go envset GOARCH=amd64set GOBIN=set GOEXE=.exeset GOHOSTARCH=amd64set GOHOSTOS=windowsset GOOS=windowsset GOPATH=C:\Users\Administrator\goset GORACE=set GOROOT=C:\Goset GOTOOLDIR=C:\Go\pkg\tool\windows_amd64set GCCGO=gccgoset CC=gccset GOGCCFLAGS=-m64 -mthreads -fmessage-length=0set CXX=g++set CGO_ENABLED=1set PKG_CONFIG=pkg-configset CGO_CFLAGS=-g -O2set CGO_CPPFLAGS=set CGO_CXXFLAGS=-g -O2set CGO_FFLAGS=-g -O2set CGO_LDFLAGS=-g -O2
4. 下載代碼,測試代碼
Microsoft Windows [版本 6.1.7601]著作權 (c) 2009 Microsoft Corporation。著作權所有,並保留一切權利。C:\Users\Administrator>cd C:\Users\Administrator\goC:\Users\Administrator\go>go get github.com/Workiva/go-datastructures/...C:\Users\Administrator\go>go get -u github.com/Workiva/go-datastructures/...C:\Users\Administrator\go>cd srcC:\Users\Administrator\go\src>cd github.comC:\Users\Administrator\go\src\github.com>cd WorkivaC:\Users\Administrator\go\src\github.com\Workiva>cd go-datastructuresC:\Users\Administrator\go\src\github.com\Workiva\go-datastructures>go get -t -u./...C:\Users\Administrator\go\src\github.com\Workiva\go-datastructures>go test ./...? github.com/Workiva/go-datastructures [no test files]ok github.com/Workiva/go-datastructures/augmentedtree 2.126sok github.com/Workiva/go-datastructures/batcher 1.363sok github.com/Workiva/go-datastructures/bitarray 1.581sok github.com/Workiva/go-datastructures/btree/immutable 15.153sok github.com/Workiva/go-datastructures/btree/palm 1.064sok github.com/Workiva/go-datastructures/btree/plus 1.783sok github.com/Workiva/go-datastructures/cache 0.820s? github.com/Workiva/go-datastructures/common [no test files]ok github.com/Workiva/go-datastructures/fibheap 1.669sok github.com/Workiva/go-datastructures/futures 0.614sok github.com/Workiva/go-datastructures/hashmap/fastinteger 1.228sok github.com/Workiva/go-datastructures/list 2.105s? github.com/Workiva/go-datastructures/mock [no test files]ok github.com/Workiva/go-datastructures/numerics/hilbert 0.640sok github.com/Workiva/go-datastructures/numerics/optimization 1.128sok github.com/Workiva/go-datastructures/queue 0.696sok github.com/Workiva/go-datastructures/rangetree 1.715sok github.com/Workiva/go-datastructures/rangetree/skiplist 1.274s? github.com/Workiva/go-datastructures/rtree [no test files]ok github.com/Workiva/go-datastructures/rtree/hilbert 1.655sok github.com/Workiva/go-datastructures/set 0.662sok github.com/Workiva/go-datastructures/slice 0.761sok github.com/Workiva/go-datastructures/slice/skip 1.057sok github.com/Workiva/go-datastructures/sort 1.279sok github.com/Workiva/go-datastructures/threadsafe/err 0.714sok github.com/Workiva/go-datastructures/tree/avl 1.533sok github.com/Workiva/go-datastructures/trie/ctrie 13.429sok github.com/Workiva/go-datastructures/trie/dtrie 0.713sok github.com/Workiva/go-datastructures/trie/xfast 1.482sok github.com/Workiva/go-datastructures/trie/yfast 1.070sC:\Users\Administrator\go\src\github.com\Workiva\go-datastructures>
5. 簡單使用
開啟 ”LiteIDE“ , 檔案 -> 開啟目錄 -> 選擇 "C:\Users\Administrator\go\src" 下的 github.com 目錄
效果如下:
右擊 LiteIDE 中的 "github.com" 選擇 “建立目錄” 輸入 "src" -> 點擊“建立”
右擊 “src” 目錄 選擇 “建立檔案”輸入 “main.go” 點擊 “建立並編輯”
測試代碼如下:
package mainimport ("fmt""github.com/Workiva/go-datastructures/list")func main() {ll := list.Emptyfmt.Println(ll.IsEmpty())ll = ll.Add(10)ll = ll.Add(12)ll = ll.Add(14)fmt.Println(ll.Length())var i uintfor i = 0; i < ll.Length(); i++ {item, ok := ll.Get(i)if ok {fmt.Println("item(", i, ") = ", item)}}fmt.Println("------------------------------------")tmp, err := ll.Insert("Hello World!", ll.Length())if err != nil {fmt.Println("list insert err: ", err)} else {ll = tmp}for i = 0; i < ll.Length(); i++ {item, ok := ll.Get(i)if ok {fmt.Println("item(", i, ") = ", item)}}fmt.Println("------------------------------------")}
右擊 “src” 選擇 “鎖定編譯目錄” 編譯運行,輸出如下:
true3item( 0 ) = 14item( 1 ) = 12item( 2 ) = 10------------------------------------item( 0 ) = 14item( 1 ) = 12item( 2 ) = 10item( 3 ) = Hello World!------------------------------------成功: 進程結束代碼 0.