Golang 설치 하기(Window)

2021. 11. 4. 13:13Golang

1. golang Download 사이트 접속 후 Microsoft Windows 다운로드 및 설치

https://golang.org/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

golang.org

 

2. GO 환경변수 설정

   설치하였을때 환경설정이 이미 되어 있었다. (없으면 추가 필요)

 

 

 

3. GOPATH

 

폴더 안에 반드시 bin, pkg, src 3개의 폴더를 만들어야 한다.
각각의 역할은 다음과 같다.


bin 폴더 : *.go 소스코드 컴파일을 하면, 실행 가능한 바이너리 파일이 저장된다.
pkg 폴더 : 프로젝트에 필요한 패키지가 컴파일 되어, 라이브러리 파일이 저장된다.
src 폴더 : 사용자가 작성한 소스코드나 사용하려는 오픈소스를 저장하는 곳이다.

 

 

4. Go 환경 설정 확인

 

Cmd창

go version : 버전 확인

go env : 환경설정 확인

 

5. 테스트

 

메모장에 아래 코드 입력 후 go 확장자로 저장

package main

import "fmt"

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

 

CMD 창에 go 명령어 입력

 

go build test.go : 빌드

go run test.go : 실행

 

6. go IDE 설치(Atom)

 

Go관련 패키지 설치

 

1. Go-plus : Go 개발 시 code-assistance 및 편리 기능 제공

2. Script : 각종 프로그래밍 언어 실행 제공

3. platformio-ide-terminal : Atom 에디터에서 command-line 콘솔 제공