bigmac-jp blog

web開発関連のメモ

GO 入門1

ざっくりめも その1

homebrewでGoインストール

$ brew install go
$ go version
go version go1.11.2 darwin/amd64

実行

$ vi test.go

package main

import("fmt")

func main(){
	fmt.Println("hello world")
}

$ go run test.fo
hello world

コンパイル

実行形式のバイナリファイルが作成される。

$ go build test.go
$ ls
$ ./test
hello world

フォーマット

go標準規約にフォーマットする

$ go fmt test.go