mieki256's diary



2025/11/19(水) [n年前の日記]

#1 [golang] Go 1.25.4をMSYS2上でインストールした

Windows11 x64 25H2 + MSYS2 MINGW64上で Go言語(golang) をインストールしておいたとメモ。

pacman -S mingw-w64-x86_64-go
pacman -S mingw-w64-i686-go

以下も必要になる。たぶん。
pacman -S git
pacman -S gcc
pacman -S base-devel
pacman -S mingw-w64-x86_64-toolchain

この状態でGo言語のバージョンを確認しようとして go version と打ったら「GOROOTが見つからない」とエラーになった。環境変数 GOROOT を設定する必要があるらしい。

~/.bashrc 内で以下を記述。
case "${MSYSTEM}" in
MINGW32)
  export GOROOT=/mingw32/lib/go
  export GOPATH=$HOME/gocode
  export GOOS=windows
  export GOARCH=386
  ;;
MINGW64)
  export GOROOT=/mingw64/lib/go
  export GOPATH=$HOME/gocode
  export GOOS=windows
  export GOARCH=amd64
  ;;
*)
esac
export PATH=$PATH:$GOPATH/bin:$GOROOT/bin

$ go version
go version go1.25.4 windows/amd64

$ gcc --version
gcc.exe (Rev8, Built by MSYS2 project) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ただ、GOROOT の設定行をコメントアウトして、bash を再起動してみたら、GOROOT に値が設定されていた…。単にシェル(?)の再起動が必要だっただけかもしれない…。

$ echo $GOROOT
/mingw64/lib/go

まあ、GOPATH、GOOS、GOARCH は設定しないとダメなのだろうから、~/.bashrc 内の記述は必要なのだろう…。たぶん。

以上です。

過去ログ表示

Prev - 2025/11 - Next
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30

カテゴリで表示

検索機能は Namazu for hns で提供されています。(詳細指定/ヘルプ


注意: 現在使用の日記自動生成システムは Version 2.19.6 です。
公開されている日記自動生成システムは Version 2.19.5 です。

Powered by hns-2.19.6, HyperNikkiSystem Project