eubnara / study

6 stars 2 forks source link

go 기초 문서 읽기 #255

Open eubnara opened 2 years ago

eubnara commented 2 years ago

https://go.dev/doc/

go modules

eubnara commented 2 years ago

https://go.dev/doc/tutorial/getting-started

eubnara commented 2 years ago

https://go.dev/doc/tutorial/create-module

go 파일 -> 패키지 -> 모듈

# 로컬 모듈 참조하게 만들기
go mod edit -replace example.com/greetings=../greetings

# semantic version number 가 없는 로컬 모듈에 대해서  pseudo-version number 를 추가한다.
go mod tidy
eubnara commented 2 years ago

https://go.dev/tour/flowcontrol/13

defer 로 함수호출을 하면 stack 형태로 last in first out 호출이 된다.

eubnara commented 2 years ago

type assertions https://go.dev/tour/methods/15

t := i.(T) // T 타입이 아니면 panic 발생할 수 있음
t, ok := i.(T) // T 타입이 아니어도 panic 발생하지 않음

map 을 접근하는 형태와 유사

elem = m[key]
elem, ok := m[key]