본문 바로가기
Golang

Golang 설치하는 방법(Mac OS)

by keymomo 2022. 8. 13.

Mac에서 golang 설치를 하기 위해 아래 경로로 이동!

 

https://go.dev/dl/

 

Downloads - The Go Programming Language

Downloads After downloading a binary release suitable for your system, please follow the installation instructions. If you are building from source, follow the source installation instructions. See the release history for more information about Go releases

go.dev

 

원하는 version 선택 및 pkg로 설치할 것인지 source를 내려받을 것인지 결정 후 해당 파일을 클릭!

(필자 환경에 맞춰 go1.19.darwin-amd64.tar.gz를 다운로드)

 

 

tar 파일의 다운로드가 완료된 후 압축을 해제한다.

tar xvf go1.19.darwin-amd64.tar.gz

 

 

압축을 해제한 후 파일들이 정상적으로 다운로드 되었는지 확인한다.

 

 

정상적으로 내려받았다면 자신의 기본 쉘(shell) 환경에 맞게 환경 변수를 설정한다.(필자는 zsh를 사용하므로 .zshrc를 수정한다.)

vi ~/.zshrc

 

 

아래와 같이 GOROOT를 내려받은 go의 경로로 지정하고, PATH에 추가한다.  

export GOROOT="/Users/keymomo/go"
export PATH="$GOROOT/bin:$PATH"

 

 

수정된 .zshrc를 적용!

source ~/.zshrc

 

 

아무 folder 또는 directory 이동 후 go version 명령 입력 후 잘 실행이 되는지 확인한다. 

go version

 

 

아래와 같이 버전이 출력된다면 정상적으로 설치 완료.