golang 메모장

Roeniss Moon·2020년 11월 15일
0

package vs command

In the most basic terms, A package is nothing but a directory inside your Go workspace containing one or more Go source files, or other Go packages.

By convention, Executable programs (the ones with the 'main' package) are called Commands. Others are called simply Packages.

go run

단일 파일 테스트

go build vs go install

For packages:

go build builds your package then discards the results.
go install builds then installs the package in your $GOPATH/pkg directory.

반면,

For commands (package 'main'):

go build builds the command and leaves the result in the current working directory.
go install builds the command in a temporary directory then moves it to $GOPATH/bin.

go mod

go get은 이제 필수 사항이 아니라는 점

standard command인 go build / go test 같은걸 하면 자동으로 go.mod가 업데이트되고 필요하면 다운로드 한다. 하지만 특정 버전이 필요할 경우 go get을 쓰기도 하는 듯.

버저닝 : "v0.0.0" 형태의 github tag

Daily Workflow with go mod :

(go mod init github.com/roeniss/my-go-module 먼저)

1) Add import statements to your .go code as needed.

2) go get -u ./... or go get -u=patch ./... (from module root directory) — Update all direct and indirect dependencies to latest minor or patch upgrades

3) go build ./... or go test ./... (from module root directory) — Build or test all packages in the module

4) go mod tidy — Prune

+) go mod graph : 의존성 트리 보기

profile
기능이 아니라 버그예요

0개의 댓글