Skip to content

Commit d3984ed

Browse files
committed
Added
1 parent 3fcee72 commit d3984ed

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

golang-dependencies.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Title: Golang: Dependencies
2+
Tags: golang,golang-dependencies
3+
4+
You can add libraries from the internet into your workspace with the 'go get' tool. If you wanted to get the memcache library you would run:
5+
6+
go get github.com/bradfitz/gomemcache/memcache
7+
8+
'go get' understands the url, and plenty of others, to grab the go files in the memcache directory of that repository, put them in your src folder in $GOPATH/src/github.com/bradfitz/gomemcache/memcache/ and build the library to place them in $GOPATH/pkg/github.com/bradfitz/gomemcache/memcache.a.
9+
10+
This will automatically grab any dependencies that gomemcache has.
11+
12+
In your main file, you can reference it by referencing the namespace that's now in your $GOPATH/src/ and $GOPATH/YOUR_ARCH/pkg/ directories.
13+
14+
package main
15+
16+
import "fmt"
17+
import "github.com/bradfitz/gomemcache/memcache"
18+
19+
func main() {
20+
fmt.Printf("Hello, world.\n")
21+
memcache.New("10.0.0.1:11211", "10.0.0.2:11211", "10.0.0.3:11212")
22+
}
23+
24+
This shows go to use the external library we included above. It obviously does nothing.
25+
26+
When you next install your golang program, it will be statically linked against gomemcache.

0 commit comments

Comments
 (0)