**클로저(closure)**는 주변 스코프의 변수를 참조하는 함수로, 그 변수들을 "감싸(close over)"줍니다 — 둘러싼 함수가 반환된 후에도 그 변수들에 대한 접근을 유지합니다. Go 함수는 일급 값이므로, 클로저는 흔하고 강력한 도구입니다.
기본 클로저
{
count :=
{
count++
count
}
}
counter := makeCounter()
fmt.Println(counter())
fmt.Println(counter())
other := makeCounter()
fmt.Println(other())
