apt-get install golang
GOPATH
GOROOT
go env
go mod init
go version
go list -m all
Example of make chan
package main
import "fmt"
func sum(s []int, c chan int) {
sum := 0
for _, v := range s {
sum += v
}
c <- sum // send sum to c
}
func main() {
//s := []int{7, 2, 8, -9, 4, 0}
s := []int{2,2,4,1,1,1}
c := make(chan int)
c1 := make(chan int)
go sum(s[:len(s)/3], c)
go sum(s[len(s)/3:2*len(s)/3], c1)
go sum(s[2*len(s)/3:], c)
//x, y := <-c, <-c // receive from c
x, y, z := <-c, <-c1, <-c // receive from c
fmt.Println(x, y, z, x+y+z)
}
Output:
2 5 4 11
Useful link: https://tour.golang.org/concurrency/2
tags creation
root@minion1:~/personal/foss/dockerhack/cadvisor# apt install ctags
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'exuberant-ctags' instead of 'ctags'
exuberant-ctags is already the newest version (1:5.9~svn20110310-11).
The following packages were automatically installed and are no longer required:
gconf-service gconf-service-backend gconf2 gconf2-common helix-p4d-base-16.1 libavahi-glib1 libbonobo2-0 libbonobo2-common
libbz2-dev libcanberra0 libcurl4-openssl-dev libgconf-2-4 libgnome-2-0 libgnome2-common libgnomevfs2-0 libgnomevfs2-common
libllvm3.8 liborbit-2-0 libruby2.3 libtdb1 libtext-unidecode-perl libvorbisfile3 libxml-libxml-perl
libxml-namespacesupport-perl libxml-parser-perl libxml-sax-base-perl libxml-sax-expat-perl libxml-sax-perl rake ruby
ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit ruby2.3 rubygems-integration
sound-theme-freedesktop tex-common texinfo unzip zip
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
root@minion1:~/personal/foss/dockerhack/cadvisor# ctags --version
Exuberant Ctags 5.9~svn20110310, Copyright (C) 1996-2009 Darren Hiebert
Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex
root@minion1:~/personal/foss/dockerhack/cadvisor# ctags -R ./
ctags: Warning: ignoring null tag in ./pages/assets/js/bootstrap-4.0.0-beta.2.min.js
ctags: Warning: ignoring null tag in ./pages/assets/js/bootstrap-4.0.0-beta.2.min.js
ctags: Warning: ignoring null tag in ./pages/assets/js/bootstrap-4.0.0-beta.2.min.js
ctags: Warning: ignoring null tag in ./pages/assets/js/bootstrap-4.0.0-beta.2.min.js
ctags: Warning: ignoring null tag in ./pages/assets/js/bootstrap-4.0.0-beta.2.min.js
ctags: Warning: ignoring null tag in ./pages/assets/js/bootstrap-4.0.0-beta.2.min.js
....
ctags: Warning: ignoring null tag in ./vendor/github.com/influxdb/influxdb/models/points.go
root@minion1:~/personal/foss/dockerhack/cadvisor#
root@minion1:~/personal/foss/dockerhack/cadvisor# ls -l tags
-rw-r--r-- 1 root root 21309119 Jan 27 16:36 tags
root@minion1:~/personal/foss/dockerhack/cadvisor# ls
AUTHORS Makefile cache collector docs info metrics tags vendor
CHANGELOG.md README.md cadvisor.go container events integration pages test.htdigest version
CONTRIBUTING.md accelerators cadvisor.go_1 cscope.out fs logo.png storage test.htpasswd zfs
Godeps api cadvisor_test.go deploy healthz machine storagedriver.go utils
LICENSE build client devicemapper http manager summary validate
root@master1:~/personal/foss/cadvisor# cat tags | grep cadvisor.go | wc -l
25
GOPATH is important env variable. it is used by 'go get' which stores the source code in $GOPATH/src
https://wiki.ubuntu.com/Go
https://tecadmin.net/install-go-on-macos/
https://medium.com/@bnprashanth256/dependency-management-and-vendoring-in-go-golang-5ec6d6b7590e
https://blog.golang.org/migrating-to-go-modules