---
# System prepended metadata

title: golang 開發環境
tags: [zsh]

---

# 安裝gvm
* [gvm](https://github.com/moovweb/gvm)

```bash
sudo apt-get install bison

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
```

# 安裝go 1.20+
```
gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.17.13
gvm use go1.17.13
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.20
gvm use go1.20 --default
gvm list
```

# 安裝Extensions
* [go](https://marketplace.visualstudio.com/items?itemName=golang.Go)

```json=
"[go]": {
    "editor.insertSpaces": true,
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "golang.go"
  }
```

# 安裝 air
* [air](https://github.com/cosmtrek/air)

```
go install github.com/cosmtrek/air@latest
air init
air
```