본 게시글은 Golang Tutorial for Beginners | Full Go Course을 학습하며 작성한 개인 노트입니다.
module path
에는 레포지토리 이름 사용하면 됨터미널에
go mod init <module path>
go.mod
파일이 생성됨: 이름/모듈 경로와 Go 버전 명시package main
Go 프로젝트에 여러 파일이 존재할 때 어디서부터 실행해야할지 명시해야 함
Go 프로그램의 entrypoint는 main function
이다
package main
func main() {
Print("Hello World")
}
Go programs are organized into packages
Go's standard library provides core packages to use
(ex) fmt provides print function
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}
import (
"fmt"
"strings"
)
imported packages must be used; otherwise error
go run main.go