1 개요[ | ]
- go mod 헬로우 월드
- go mod init 헬로우 월드
- $HOME/hello에서 go mod init 하고 hello.go 파일 만들고 실행
한방 스크립트
Bash
Copy
mkdir hello
cd hello
go mod init example/hello
cat go.mod
cat <<EOF > hello.go
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
EOF
go run .
실행예시
Console
Copy
testuser@localhost:~$ mkdir hello
testuser@localhost:~$ cd hello
testuser@localhost:~/hello$ go mod init example/hello
go: creating new go.mod: module example/hello
Console
Copy
testuser@localhost:~/hello$ cat go.mod
module example/hello
go 1.17
Console
Copy
testuser@localhost:~/hello$ cat <<EOF > hello.go
> package main
> import "fmt"
> func main() {
> fmt.Println("Hello, World!")
> }
> EOF
Console
Copy
testuser@localhost:~/hello$ go run .
Hello, World!
2 같이 보기[ | ]
3 참고[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.