Golang Windows 환경변수 설정

보통 인터넷 검색해보거나 과거에 golang 책 사서 보면 환경 설정할때

GOROOT
GOPATH
GOBIN

위 세가지 항목을 등록해야 했는데 요즘 해보니 바뀌어서 여기 정리해봄.

msi파일로 설치하면 자동으로 등록되긴 하는데 경로가 디폴트값으로 등록되는 문제가 있음.
그래서 본인은 zip파일로 받아서 폴더 덮어쓰기로 sdk 업데이트를 함.
환경설정은 처음엔 수동으로 등록하다가 나중엔 간단하게 등록하는 App을 하나 만듬

1. GOPATH

GOPATH는 내가 작업할 소스라던지 go get으로 받을 workspace 루트 폴더를 말합니다.
(위 스샷은 VirtualPC로 테스트 한 스샷입니다.)

2. %GOPATH%bin

사용자 변수중 Path 항목에 앞에 지정한 GOPATH의 하위 Bin 경로를 지정해줌.

3.GOBIN???

시스템 변수 중 Path 항목에 go SDK 경로의 bin 폴더가 추가됨.
이게 멀티유저 계정 고려해서 시스템 Path에 추가 한거 같은데 사용자변수 path에 추가해도 사용하는데는 전혀 문제가 없음.

 

GOROOT가 언제 없어졌나 검색해보니 1.10 버전에서 사라진걸로 나옴.

Default GOROOT & GOTMPDIR
If the environment variable $GOROOT is unset, the go tool previously used the default GOROOT set during toolchain compilation. Now, before falling back to that default, the go tool attempts to deduce GOROOT from its own executable path. This allows binary distributions to be unpacked anywhere in the file system and then be used without setting GOROOT explicitly.

By default, the go tool creates its temporary files and directories in the system temporary directory (for example, $TMPDIR on Unix). If the new environment variable $GOTMPDIR is set, the go tool will creates its temporary files and directories in that directory instead.

구글 번역기
기본 GOROOT 및 GOTMPDIR
환경 변수 $ GOROOT가 설정되지 않은 경우 go 도구는 이전에 도구 체인 컴파일 중에 설정된 기본 GOROOT를 사용했습니다. 이제 기본값으로 돌아 가기 전에 go 도구는 자체 실행 경로에서 GOROOT를 추론하려고 시도합니다. 이를 통해 파일 시스템의 어느 곳에서나 바이너리 배포를 풀고 GOROOT를 명시 적으로 설정하지 않고도 사용할 수 있습니다.

기본적으로 go 도구는 시스템 임시 디렉토리 (예 : Unix의 $ TMPDIR)에 임시 파일 및 디렉토리를 만듭니다. 새 환경 변수 $ GOTMPDIR이 설정된 경우 go 도구는 대신 해당 디렉토리에 임시 파일 및 디렉토리를 작성합니다.


Comments

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다