티스토리 뷰

APT-GET 

# apt 패키지 업데이트
sudo apt-get update
sudo apt-get -y upgrade

# wget 설치
sudo apt-get install wget

 

1.17버전 다운로드

wget https://golang.org/dl/go1.17.linux-amd64.tar.gz

최신버전이나 특정 버전이 설치하고 싶다면 아래의 링크에서 확인할 수 있다

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

 

위에서 다운로드 한 tar파일 압축해제

tar -xvf go1.17.linux-amd64.tar.gz

 

 

환경변수 설정

centos7의 경우 vim ~/.bashrc

ubuntu20의 경우 vim $HOME/.profile

sudo vi $HOME/.profile

# GOROOT: 설치된 Go 패키지의 경로
export GOROOT=$HOME/go 

# GOPATH: Go 패키지를 이용해 작업할 공간
export GOPATH =/project/gogo

# 동일
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

이처럼 환경변수 설정을 해야하는데 터미널청에서 그냥 export만 해버리면 환경변수가 영구적으로 등록되지 않는다

 

방법은

vim ~/.bashrc

이 파일의 맨 밑줄에 위의 환경변수를 등록한 후

. ./.profile

를 해주고

echo $GOROOT

이렇게 테스트 하면 완료

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함