Windowsでもgolang
golang-nutsを見てたら、つい15分ほど前に「Download initial Windows port of go here」なんていう投稿があったので早速落として試してみた。
- まず http://code.google.com/p/go-windows/ から go-1.zip をダウンロードして解凍します。
- goディレクトリを適当な場所(ここではとりあえずC:\go)に置いて以下のように環境変数を設定します。
set GOROOT=C:\go set GOOS=mingw set GOARCH=386 set PATH=%PATH%;%GOROOT%\bin
- cmd.exeで8gと打つと確かに普通に使えそうです。
C:\Users\kawaz\Desktop\gotest>8g flags: -I DIR search for packages in DIR -d print declarations -e no limit on number of errors printed -f print stack frame structure -h panic on an error -k name specify package name -o file specify output file -S print the assembly language -w print the parse tree after typing -x print lex tokens
- hello.goを作って…
package main func main() { println("WindowsでもGo!!"); }
- コンパイル&実行してみました。
C:\Users\kawaz\Desktop\gotest>8g -o hello.8 hello.go C:\Users\kawaz\Desktop\gotest>8l -o hello.exe hello.8 C:\Users\kawaz\Desktop\gotest>hello.exe Windows縺ァ繧・o!!
C:\Users\kawaz\Desktop\gotest>chcp 65001 Active code page: 65001 C:\Users\kawaz\Desktop\gotest>hello.exe WindowsでもGo!!
- 一応動くことは確認できました!
goディレクトリの中身ですが bin ディレクトリの中には 6nm 8a 8c 8g 8l gopack だけという必要最小限のコマンドがあり、pkgディレクトリを見るとosやruntimeやfmtなどの基本的なパッケージは大体用意されてるようですが、http パッケージが無いなど足りないモノもまだ多いようです。