go mod tidy 헬로우 월드

1 개요[ | ]

go mod tidy 헬로우 월드
  • $HOME/hello2에서 go mod init 하고 hello.go 파일 만들고 go mod tidy 하고 실행
한방 스크립트
mkdir hello2
cd hello2
go mod init example/hello2
cat go.mod
cat <<EOF > hello2.go
package main
import "fmt"
import "rsc.io/quote"
func main() {
    fmt.Println("Hello, World2")
    fmt.Println(quote.Go())
}
EOF
go mod tidy
go run .
실행예시
testuser@localhost:~$ mkdir hello2
testuser@localhost:~$ cd hello2
testuser@localhost:~/hello$ go mod init example/hello2
go: creating new go.mod: module example/hello2
testuser@localohst:~/hello2$ cat go.mod
module example/hello2

go 1.17
testuser@localhost:~/hello2$ cat <<EOF > hello2.go
> package main
> import "fmt"
> import "rsc.io/quote"
> func main() {
>     fmt.Println("Hello, World2")
>     fmt.Println(quote.Go())
> }
> EOF
testuser@localhost:~/hello2$ go mod tidy
go: finding module for package rsc.io/quote
go: downloading rsc.io/quote v1.5.2
go: found rsc.io/quote in rsc.io/quote v1.5.2
go: downloading rsc.io/sampler v1.3.0
go: downloading golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c
testuser@localhost:~/hello2$ go run .
Hello, World2
Don't communicate by sharing memory, share memory by communicating.

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}