GO uses an open source data structure

Source: Internet
Author: User
Tags install go
This is a creation in Article, where the information may have evolved or changed.

1. Platform Windows, installing git

2. Install Go 1.3+

3. View Gopath Information

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. Download the code, test the code

Microsoft Windows [version 6.1.7601] Copyright (c) Microsoft Corporation. All rights reserved. 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.1 26sok 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 gi       Thub.com/workiva/go-datastructures/cache 0.820s? Github.com/workiva/go-datastructures/common [No test files]ok github.com/workiva/go-datastructures/fibheap 1.6 69sok github.com/workiva/go-datastructures/futures 0.614sok Github.com/workiva/go-datastructures/hashmap/fast       Integer 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/hilbe RT 0.640sok Github.com/workiva/go-datastructures/numerics/optimization 1.128sok Github.com/workiva/go-dat Astructures/queue 0.696sok github.com/workiva/go-datastructures/rangetree 1.715sok github.com/workiva/go-d       Atastructures/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.6 62sok 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-datastructur Es/trie/xfast 1.482sok Github.com/workiva/go-datastructures/trie/yfast 1.070sc:\users\administrator\go\src\ Github.com\workiva\go-datastructures>

5. Simple to use

Open "Liteide", open Directory, file, select the github.com directory under "C:\Users\Administrator\go\src"

The effect is as follows:

Right-click "github.com" in Liteide Select "New directory" input "src", click "New"

Right click on "src" directory Select "New file" enter "Main.go" click "New and edit"

The test code is as follows:

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("------------------------------------")}

Right-click on "src" to select "Lock compile directory" compile run, output as follows:

true3item( 0 ) =  14item( 1 ) =  12item( 2 ) =  10------------------------------------item( 0 ) =  14item( 1 ) =  12item( 2 ) =  10item( 3 ) =  Hello World!------------------------------------成功: 进程退出代码 0.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.