go get으로 설치된 패키지 제거
루트 Go 설치에 적합하지 않은 패키지 go get package
를 설정해야한다는 것을 배우기 전에 패키지를 다운로드하기 위해 뛰었습니다 GOPATH
(Go 설치를 깨끗하게 유지하고 코어를 사용자 정의와 분리하는 것을 선호합니다). 이전에 설치된 패키지를 어떻게 제거합니까?
소스 디렉토리와 컴파일 된 패키지 파일을 삭제하는 것이 안전합니다. 아래에서 소스 디렉토리 $GOPATH/src
와 패키지 파일을 찾으십시오 ( $GOPATH/pkg/<architecture>
예 :) $GOPATH/pkg/windows_amd64
.
당신은 아카이브 파일 것을 실행 바이너리를 삭제할 수 있습니다 go install
(또는 go get
)와 패키지 생산을 go clean -i importpath...
. 이들은 일반적으로 $GOPATH/pkg
및 아래 $GOPATH/bin
에 있습니다.
...
패키지에 실행 파일이 포함 된 경우 아래 예 go clean -i
와 같이 하위 패키지에 대한 파일을 아카이브하지 않고 제거 할 것이므로 importpath 에 포함시켜야 gore/gocode
합니다.
그런 다음 소스 코드를에서 수동으로 제거해야 $GOPATH/src
합니다.
go clean
가 -n
당신이 확신 할 수 있도록, 그것을 실행하지 않고 실행됩니다 어떤 인쇄 (참조하는 건조 실행에 대한 플래그 go help clean
). 또한 -r
의존성을 재귀 적으로 정리 하려는 유혹 플래그가 있습니다. 건조한 실행에서 많은 표준 라이브러리 아카이브 파일이 삭제된다는 것을 알기 때문에 실제로 사용하고 싶지 않을 것입니다!
원하는 경우 스크립트를 기반으로 할 수있는 완전한 예제 :
$ go get -u github.com/motemen/gore
$ which gore
/Users/ches/src/go/bin/gore
$ go clean -i -n github.com/motemen/gore...
cd /Users/ches/src/go/src/github.com/motemen/gore
rm -f gore gore.exe gore.test gore.test.exe commands commands.exe commands_test commands_test.exe complete complete.exe complete_test complete_test.exe debug debug.exe helpers_test helpers_test.exe liner liner.exe log log.exe main main.exe node node.exe node_test node_test.exe quickfix quickfix.exe session_test session_test.exe terminal_unix terminal_unix.exe terminal_windows terminal_windows.exe utils utils.exe
rm -f /Users/ches/src/go/bin/gore
cd /Users/ches/src/go/src/github.com/motemen/gore/gocode
rm -f gocode.test gocode.test.exe
rm -f /Users/ches/src/go/pkg/darwin_amd64/github.com/motemen/gore/gocode.a
$ go clean -i github.com/motemen/gore...
$ which gore
$ tree $GOPATH/pkg/darwin_amd64/github.com/motemen/gore
/Users/ches/src/go/pkg/darwin_amd64/github.com/motemen/gore
0 directories, 0 files
# If that empty directory really bugs you...
$ rmdir $GOPATH/pkg/darwin_amd64/github.com/motemen/gore
$ rm -rf $GOPATH/src/github.com/motemen/gore
이 정보는 go
Go 버전 1.5.1 의 도구를 기반으로합니다 .
#!/bin/bash
goclean() {
local pkg=$1; shift || return 1
local ost
local cnt
local scr
# Clean removes object files from package source directories (ignore error)
go clean -i $pkg &>/dev/null
# Set local variables
[[ "$(uname -m)" == "x86_64" ]] \
&& ost="$(uname)";ost="${ost,,}_amd64" \
&& cnt="${pkg//[^\/]}"
# Delete the source directory and compiled package directory(ies)
if (("${#cnt}" == "2")); then
rm -rf "${GOPATH%%:*}/src/${pkg%/*}"
rm -rf "${GOPATH%%:*}/pkg/${ost}/${pkg%/*}"
elif (("${#cnt}" > "2")); then
rm -rf "${GOPATH%%:*}/src/${pkg%/*/*}"
rm -rf "${GOPATH%%:*}/pkg/${ost}/${pkg%/*/*}"
fi
# Reload the current shell
source ~/.bashrc
}
용법:
# Either launch a new terminal and copy `goclean` into the current shell process,
# or create a shell script and add it to the PATH to enable command invocation with bash.
goclean github.com/your-username/your-repository
참고URL : https://stackoverflow.com/questions/13792254/removing-packages-installed-with-go-get
'Programming' 카테고리의 다른 글
Promise.all에서 오류 처리 (0) | 2020.05.09 |
---|---|
자식은 파일을 어떻게 저장합니까? (0) | 2020.05.09 |
CMake를 사용하여 포함 디렉토리를 올바르게 추가하는 방법 (0) | 2020.05.09 |
클래스의 함수 선언 후 "default"는 무엇을 의미합니까? (0) | 2020.05.09 |
가상 함수와 순수한 가상 함수의 차이점 (0) | 2020.05.09 |