Programming/Go

[Go] Go 실행 파일 설치 ( go get ~ -> go install ~)

owls 2021. 10. 19. 12:20
728x90

1. go get

Golang을 다운로드 받고 실행 파일을 설치하려고 할 때

   "go get golang.org/x/tools/cmd/... " 명령어를 사용해서 설치하라는 정보가 많이 나올겁니다.

저도 검색해가면서 설치해서 처음에는 go get~ 을 사용해서 실행 파일을 설치했습니다.

go get

설치 파일이 다운로드는 됬지만 마지막에 

go get: installing executables with 'go get' in module mode is deprecated.
        Use 'go install pkg@version' instead.
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.

이라는 메시지가 나옵니다.

 

찾아보니 Go 1.17부터는 "go get"에 대한 지원을 중단한다고 합니다! 

https://golang.org/doc/go-get-install-deprecation#what-to-use-instead

 

Deprecation of 'go get' for installing executables - The Go Programming Language

Deprecation of 'go get' for installing executables Overview Starting in Go 1.17, installing executables with go get is deprecated. go install may be used instead. In a future Go release, go get will no longer build packages; it will only be used to add, up

golang.org

 

2. go install

"go get" 대신 "go install" 을 사용해서 설치하라고 나와있네요~

https://golang.org/ref/mod#go-install

 

Go Modules Reference - The Go Programming Language

 

golang.org

go install을 사용해서 다시 설치를 해보겠습니다. 옵션 사용법은 golang 페이지에 잘 나와있습니다~

이런식으로 사용하라고 나와있습니다.

 

Install all programs in a directory를 해보려고 합니다.

했더니!!! directory가 없다고 안된다네요...

 

그래서 Install the latest version of a program을 해봅시다!

cmd에 "go install golang.org/x/tools/gopls@latest" 명령어를 입력합니다.

설치가 아주 잘됬네요~

 

go1.17 이상 버전을 사용하실 분들은 "go install~" 을 사용하시면 됩니다~

 

3. go get , go install 비교

  "go get golang.org/x/tools/cmd/... " 

"go install golang.org/x/tools/gopls@latest" 실행 결과 설치되는 파일을 비교해 보았는데 차이가 있습니다.

차이가 나는 이유는 좀더 찾아보고 다시 업데이트 하도록 하겠습니다~

./Go/bin
./Go/pkg/mod

 

728x90