| 양쪽 이전 판 이전 판 다음 판 | 이전 판 |
| go [2026/02/18 07:56] – [USAGE] writer | go [2026/06/14 14:03] (현재) – 바깥 편집 127.0.0.1 |
|---|
| {{tag>[go golang]}} | {{tag>[go golang cli programming]}} |
| |
| ====== go ======= | ====== go ====== |
| | Go language toolchain, module management, build, test, and installation notes. |
| |
| ===== USAGE ===== | ===== Summary ===== |
| | ''go'' is the main CLI for building, testing, formatting, and managing Go modules. |
| | |
| | ===== Install ===== |
| | ==== Linux ==== |
| <code bash> | <code bash> |
| | wget https://go.dev/dl/go1.26.4.linux-amd64.tar.gz |
| | sudo tar -C /usr/local -xzf go1.26.4.linux-amd64.tar.gz |
| | </code> |
| | |
| | <note warning> |
| | The tar archive installs Go under ''/usr/local/go''. If an older manual install exists in the same location, clean it up first to avoid mixed files. |
| | </note> |
| | |
| | ===== Config ===== |
| | ==== Shell Environment ==== |
| | <code bash> |
| | echo 'export GOPATH=$HOME/go' >> ~/.zshrc |
| | echo 'export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin' >> ~/.zshrc |
| | </code> |
| | |
| | <note tip> |
| | The user-provided example used ''$HOME/go/bin'' directly as ''GOPATH'', but the usual layout is ''GOPATH=$HOME/go'' and then add ''$GOPATH/bin'' to ''PATH''. |
| | </note> |
| | |
| | ===== Usage ===== |
| | <code bash> |
| | go <command> [arguments] |
| | </code> |
| | |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27><command></color> <color #22b14c>[flags]</color> <color #7092be>[arguments]</color>'' |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>mod init</color> <color #7092be>module_name</color>'' 새로운 프로젝트 시작. ''go.mod'' 파일 생성. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>mod tidy</color>'' 실제로 import 하는 패키지를 ''go.mod''에 반영하고 쓰지 않는 의존성을 정리. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>mod vendor</color>'' 외부 의존성 소스를 프로젝트 내부 ''vendor/'' 디렉토리로 복사. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>get</color> <color #7092be>package_path</color>'' 패키지를 내려받고 ''go.mod''에 추가. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>get</color> <color #7092be>package_path@version</color>'' 특정 버전 지정. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>run</color> <color #7092be>filename.go</color>'' 컴파일 후 즉시 실행. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>run</color> <color #7092be>.</color>'' 현재 모듈 실행. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>build</color>'' 컴파일. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>install</color>'' 패키지를 빌드하고 실행 파일을 ''$GOPATH/bin''에 설치. 예: ''go install github.com/zerotymer/package@latest'' |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>test</color>'' ''*_test.go'' 파일을 찾아 테스트 실행. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>fmt</color>'' Go 표준 스타일로 코드 포맷 정리. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>vet</color>'' 정적 분석으로 잠재적인 실수를 탐지. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>version</color>'' 버전 확인. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>env</color>'' 환경 설정 확인. |
| | * ''<color #c3c3c3>**go**</color> <color #ff7f27>clean</color>'' 객체 파일과 캐시 삭제. |
| | |
| | ===== Examples ===== |
| | <code bash> |
| | go version |
| | go env |
| | go mod init example.com/hello |
| | go mod tidy |
| | go run . |
| | go build |
| | go test ./... |
| | </code> |
| | |
| | ===== Help ===== |
| | ++++ go --help | |
| | <code text> |
| Go is a tool for managing Go source code. | Go is a tool for managing Go source code. |
| |
| Use "go help <topic>" for more information about that topic. | Use "go help <topic>" for more information about that topic. |
| </code> | </code> |
| | ++++ |
| | |
| | ===== See Also ===== |
| | * [[git]] |
| | * [[docker]] |
| | * [[syntax:plugins:color]] |
| | |
| | ===== History ===== |
| | * codex:: 2026-06-14 Reorganized the Go page into CLI reference format and added install and shell environment setup notes. |
| |
| * ''<color #c3c3c3>**go**</color> <color #ff7f27><command></color> <color #7092be>[arguments]</color>'' | |
| * ''<color #c3c3c3>**go**</color> <color #ff7f27>**mod init**</color> <color #7092be>module_name</color>'' 새로운 프로젝트 시작. ''go.mod'' 파일 생성됨 | |
| * ''<color #c3c3c3>**go**</color> <color #ff7f27>**get**</color> <color #7092be>package_path</color>'' 패키지 다운로드하고 go.mod에 추가. ++ overloads || \\ ''<color #c3c3c3>**go**</color> <color #ff7f27>**get**</color> <color #7092be>package_path@version</color>'' 버전 명시 | |
| * | |
| ---- struct data ---- | ---- struct data ---- |
| info.name : go | info.name : go |