- 適当なフォルダを作成
mkdir ubuntu-go
-
vscode でフォルダを開く
-
F1
でコマンドパレットを開く -
「add dev container」と入力し、 [Dev Containers: Add Development Container Configuration Files] (Dev Containers: 開発コンテナー構成ファイルの追加)を選ぶ。
-
Select a container configuration template から [Ubuntu] を選択する。
-
Ubuntu version で [jammy (default)] を選択。
-
Select additional features to install で [Go devcontainers] の チェックボックスをオンにして
OK
-> devcontainer.json が作成される。
-
F1
でコマンドパレットを開き、 [Reopen in Container] を選択する。 -
go がインストールされていることを確認
# go version
go version go1.19.4 linux/arm64
- hello.go ファイルを作成して、実行してみる。
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
# go run hello.go