7. CentOS 7에서 Go 언어 설치하기
페이지 정보
작성자 관리자 댓글 0건 조회 1,898회 작성일 21-07-09 21:41본문
[root@www ~]# yum -y install git
[root@www ~]# wget -q https://storage.googleapis.com/golang/getgo/installer_linux
[root@www ~]# chmod +x installer_linux
[root@www ~]# ./installer_linux
Welcome to the Go installer!
Downloading Go version go1.16.5 to /root/.go
This may take a bit of time...
Downloaded!
Setting up GOPATH
GOPATH has been set up!
One more thing! Run `source /root/.bash_profile` to persist the
new environment variables to your current session, or open a
new shell prompt.
[root@www ~]# source /root/.bash_profile
[root@www ~]# go version
go version go1.16.5 linux/amd64
[root@www ~]#
[root@www ~]# cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export PATH=$PATH:/root/.go/bin
export GOPATH=/root/go
export PATH=$PATH:/root/go/bin
[root@www ~]#
소스로 설치하기
[root@www ~]# cd /usr/local/
[root@www local]# wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz --no-check-certificate
--2021-07-09 21:43:51-- https://golang.org/dl/go1.16.5.linux-amd64.tar.gz
Resolving golang.org (golang.org)... 142.250.76.145, 2404:6800:4004:81f::2011
Connecting to golang.org (golang.org)|142.250.76.145|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://dl.google.com/go/go1.16.5.linux-amd64.tar.gz [following]
--2021-07-09 21:43:51-- https://dl.google.com/go/go1.16.5.linux-amd64.tar.gz
Resolving dl.google.com (dl.google.com)... 216.58.220.142, 2404:6800:4004:813::200e
Connecting to dl.google.com (dl.google.com)|216.58.220.142|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 129049763 (123M) [application/x-gzip]
Saving to: ‘go1.16.5.linux-amd64.tar.gz’
100%[======================================>] 129,049,763 73.1MB/s in 1.7s
2021-07-09 21:43:53 (73.1 MB/s) - ‘go1.16.5.linux-amd64.tar.gz’ saved [129049763/129049763]
[root@www local]# ls
[root@www local]# tar -C /usr/local/ -xzf go1.16.5.linux-amd64.tar.gz
[root@www local]# ls
실행파일 path 환경등록
# vi ~/.bash_profile
실생PATH에 추가
export PATH=$PATH:/usr/local/go/bin
# source ~/.bash_profile
GOROOT 지정 (선택사항)
: Go가 설치된 곳의 위치를 환경에 설정한다.
- 환경에 GOROOT추가
export GOROOT=/usr/local/go
- 환경적용
source ~/.bash_profile
GOPATH 지정 (필수, go get -u 패키지주소 로 패키지 설치시 GOPATH에 설치됨)
: Go 는 실제 프로그램을 할 곳인 GOPATH를 지정해야 함.(여기서는 /usr/local/go-work 를 지정할것임.)
- 일단 go-work폴더를 /usr/local하위에 만든다.
mkdir /usr/local/go_work
- 환경에 GOPATH 추가
export GOPATH=/usr/local/go_work
- 환경적용
source ~/.bash_profile
[jklee@localhost home]$ vi ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export GOPATH=/home/jklee/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
~
[jklee@localhost home]$ source ~/.bash_profile
go 설치 확인해보기 (go 명령어로 version이 잘 나오면 설치가 잘 된 것임.)
go version
[jklee@localhost home]$ go version
go version go1.16.5 linux/amd64
[jklee@localhost home]$
댓글목록
등록된 댓글이 없습니다.