【Go】Mac에 Go를 설치하기

2038 단어 5Machomebrew

개요



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 !

빌드 및 바이너리 생성 및 실행


$ 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!

좋은 웹페이지 즐겨찾기