mynote/go/install.md
2020-12-21 10:40:31 +08:00

60 lines
621 B
Markdown

# go环境部署
- Ubuntu 16.04/64
- referring to : https://golang.google.cn/doc/install
## download
- https://golang.google.cn/dl/
## install
``` bash
tar -C /usr/local -xzf go1.9.3.linux-amd64.tar.gz
```
## add path
``` bash
export PATH=$PATH:/usr/local/go/bin
```
## create workspace
``` bash
mkdir ~/go
mkdir ~/go/src
mkdir ~/go/bin
```
## hello world
``` bash
mkdir ~/go/src/hello
nano ~/go/src/hello/hello.md
```
add fellows
``` go
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
```
``` bash
cd ~/go/src/hello
go build
./hello
# or
go install
cd ~/go/bin
./hello
```