Get Start

install

https://golang.org/doc/install https://go.dev/doc/install

1. Extract the archive you downloaded into /usr/local, creating a Go tree in /usr/local/go.

$ rm -rf /usr/local/go && tar -C /usr/local -xzf go1.17.8.linux-amd64.tar.gz

2.Add /usr/local/go/bin to the PATH environment variable

$HOME/.profile or /etc/profile (for a system-wide installation)
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

$ source $HOME/.profile.

$ go version
/usr/local/go/bin/go

但是我可能对 system-wide installation 有误解,因为使用其他用户比如root之后无法找到 go,
发现 https://askubuntu.com/questions/118263/some-programs-not-found-when-used-with-sudo
不能直接vim /etc/sudoers,执行 sudo visudo
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin"

https://www.cnblogs.com/chr-wonder/p/8464224.html
当我们使用了自己 GOPATH 中的包时,sudo go run xxxx 并不会在我们环境变量指定的目录去查找包。
我们需要设置 /etc/sudoers 文件中的 Defaults env_keep 项。向其中加入我们的 GOPATH 环境变量:
Defaults    env_keep += "GOPATH"

PATH 环境变量

print env: go env

Debug with vscode

Grama

refer: https://go.dev/doc/effective_go 《an introduction to programming in go》

The blank identifier

https://stackoverflow.com/questions/27764421/what-is-underscore-comma-in-a-go-declaration

todo

Page25 Type byte uint8 rune int32 Float point number computing are inexact why? Boolean 1 bit integer

Dot single period Quote double qutation mark Back tick Space : white space ,tab, newline

Character represent by byte

Parentheses bracket Map assiocate array

Function procedures subroutine

https://golang.org/dl/ https://github.com/golang/go/wiki/SettingGOPATH make build.

go get vs git clone