windows10 scoopを使ってgo言語をインストールする
windows10でパッケージ管理ツール「scoop」を使ってgo言語をインストールする手順を記述してます。
環境
- OS windows10 pro
scoopインストール
scoopのインストールは非常に簡単で、まずは管理者権限でpowershell起動します。
powershell上で、以下のコマンドを実行します。
> Set-ExecutionPolicy RemoteSigned -scope CurrentUser
> iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
インストールが成功すると「Scoop was installed successfully!」と表示されます。
go言語インストール
まずは、検索してバージョンを確認してみます。
> scoop search go
'main' bucket:
centrifugo (2.6.0)
forego (20180217041714)
gauche (0.9.9) --> includes 'gosh.exe'
global (6.6.3) --> includes 'gozilla.exe'
go-ipfs (0.6.0)
go (1.14.6)
「1.14.6」がインストールできるので、これをインストールします。
> scoop install go
WARN Purging previous failed installation of go.
Uninstalling 'go' ().
'go' was uninstalled.
Installing 'go' (1.14.6) [64bit]
go1.14.6.windows-amd64.zip (131.4 MB) [=======================================================================] 100%
Checking hash of go1.14.6.windows-amd64.zip ... ok.
Extracting go1.14.6.windows-amd64.zip ... done.
Running installer script...
Linking ~\scoop\apps\go\current => ~\scoop\apps\go\1.14.6
Creating shim for 'go'.
Creating shim for 'gofmt'.
'go' (1.14.6) was installed successfully!
Notes
-----
Your GOROOT has been set to: C:\Users\username\scoop\apps\go\current
You can run 'go env GOROOT' to view this at any time.
"$env:USERPROFILE\go\bin" has been added to your PATH.
バージョンを確認してみます。
> go version
go version go1.14.6 windows/amd64
go実行
ここでは「hello.go」という名前で作成してます。
package main
import (
"fmt"
)
func main(){
fmt.Println("Hello, world!");
}
実行します。
> go run hello.go
Hello, world!
実行すると「Hello, world!」と表示されます。
-
前の記事
MySQL 文字列のリストから文字列を検索して位置を取得する 2022.01.06
-
次の記事
go言語 mysqlに接続してselectを実行する 2022.01.06
コメントを書く