13
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Go】MacにGoをインストールする

Posted at

概要

MacにGo言語をインストールして Hello World して環境確認するまで.

手順

$ brew install go

確認

$ go version
//バージョンが表示されたらOK

Hello World !

hello.go
package main
import "fmt"

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

Runで実行

$ go run hello.go
Hello World !

Buildしてバイナリ生成して実行

$ go build hello.go
$ ./hello
Hello World !

環境確認

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/takeharu/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/takeharu/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.6/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.6/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/p6/0ynlfrjj6ds3l9v5c0jvxt000000gn/T/go-build131527314=/tmp/go-build -gno-record-gcc-switches -fno-common"

Happy Hacking :sunglasses: !

13
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?