Skip to content

Instantly share code, notes, and snippets.

@TakesxiSximada
Last active October 14, 2016 08:55
Show Gist options
  • Save TakesxiSximada/b1b05dd17af407a3caa26d4e7f5cf7c1 to your computer and use it in GitHub Desktop.
Save TakesxiSximada/b1b05dd17af407a3caa26d4e7f5cf7c1 to your computer and use it in GitHub Desktop.
GoでHelloWorld

GoでHelloWorld

まず書いて実行する

main.go:

package main

import "fmt"

func main() {
	fmt.Print("Hello World!!\n")
}

フォーマット:

$ go fmt main.go

バイナリのビルド:

$ go build main.go

実行:

$ ./main
Hello World!!


# キーワード

- `package` パッケージ宣言
- `import` 外部パッケージのインポート
- `func` 関数宣言

# ライブラリ

- `fmt` https://golang.org/pkg/fmt/
.PHONY: run
run: build
./main
.PHONY: build
build:
go fmt main.go
go build main.go
.PHONY: exec
exec:
go run main.go
package main
import "fmt"
func main() {
fmt.Print("Hello World!!\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment