본문 바로가기
OS/linux

centos7 golang 설치하기

by Knowledge Store In Hyunsoft 2020. 1. 7.

1. 파일 다운로드

wget https://dl.google.com/go/go1.12.14.linux-amd64.tar.gz or 
curl -O https://dl.google.com/go/go1.12.14.linux-amd64.tar.gz

2. 설치

sudo tar -C /usr/local -xvzf go1.12.14.linux-amd64.tar.gz

3.1.환경설정 

vi /etc/profile.d/path.sh
export PATH=$PATH:/usr/local/go/bin

3.2.환경설정

vi ~/.bash_profile
export GOBIN="$HOME/go/bin"
export GOPATH="$HOME/go"

4. 환경 변수 적용

source /etc/profile
source ~/.bash_profile

5.확인 

vi hello.go
package main

import "fmt"

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

 6.빌드 실행 테스트

go run hello.go

go build hello.go

go install hello.go
728x90

댓글