๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ˜์‘ํ˜•

Data Base/Go28

Go failing - expected 'package', found 'EOF' Go failing - expected 'package', found 'EOF' Ctrl + s(์ €์žฅ)์„ ๋ˆ„๋ฅด๋ฉด ํ•ด๊ฒฐ์ด ๋œ๋‹ค. ๐Ÿ‘‰๐Ÿป ์ฐธ๊ณ  ์‚ฌ์ดํŠธ https://stackoverflow.com/questions/31110191/go-failing-expected-package-found-eof 2021. 11. 10.
[Golang] Map Literals ์ตœ์ƒ์œ„ ํƒ€์ž…์ด ํƒ€์ž… ์ด๋ฆ„์ผ ๊ฒฝ์šฐ, ๋ฆฌํ„ฐ๋Ÿด์˜ ์š”์†Œ์—์„œ ์ƒ๋žตํ•  ์ˆ˜ ์žˆ๋‹ค. - ๋ฆฌํ„ฐ๋Ÿด์ด ์ƒ๋žต๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ type Vertex struct { Lat, Long float64 } // ๋ฆฌํ„ฐ๋Ÿด์ด ์ƒ๋žต๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ var m = map[string]Vertex{ "Bell Labs": Vertex{ 40.68433, -74.39967, }, "Google": Vertex{ 37.42202, -122.08408, }, } func main() { fmt.Println(m) } - ๋ฆฌํ„ฐ๋Ÿด์ด ์ƒ๋žต๋œ ๊ฒฝ์šฐ type Vertex struct { Lat, Long float64 } // ๋ฆฌํ„ฐ๋Ÿด์ด ์ƒ๋žต๋œ ๊ฒฝ์šฐ var m = map[string]Vertex{ "Bell Labs": {40.68433, -74.39967}, .. 2021. 11. 2.
[Golang] Maps map์€ ํ‚ค๋ฅผ ๊ฐ’์— ๋งคํ•‘ํ•œ๋‹ค. map์˜ zero value๋Š” nil์ด๋‹ค. nil map์€ ํ‚ค๋„ ์—†๊ณ , ํ‚ค๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜๋„ ์—†๋‹ค. make ํ•จ์ˆ˜๋Š” ์ฃผ์–ด์ง„ ํƒ€์ž…์ด ์ดˆ๊ธฐํ™”๋˜๊ณ  ์‚ฌ์šฉ ์ค€๋น„๊ฐ€ ๋œ map์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค. [์ฐธ๊ณ  ์‚ฌ์ดํŠธ - a Tour of Go] 2021. 11. 2.
[Golang] range // ์ผ๋ฐ˜์ ์ธ for๋ฌธ for i := 0; i < len(pow); i++ { v := pow[i] fmt.Printf("%d %d\n", i, v) } // range๋ฅผ ์‚ฌ์šฉํ•œ ๊ตฌ๋ฌธ for i, v := range pow { fmt.Printf("%d %d\n", i, v) } [์ฐธ๊ณ  ์‚ฌ์ดํŠธ - a Tour of Go] 2021. 11. 2.
[์‰ฝ๊ณ  ๋น ๋ฅธ Go ์‹œ์ž‘ํ•˜๊ธฐ] #2.2 Methods part Two [์ถœ์ฒ˜ - Nomad Coders] accounts/accounts.go package accounts import "errors" // Account struct type Account struct { owner string balance int } var errNoMoney = errors.New("Can't withdraw") // NewAccount creates Account func NewAccount(owner string) *Account { account := Account{owner: owner, balance: 0} return &account } // Deposit x amount on your account func (a *Account) Deposit(amount int) { a.. 2021. 11. 2.
[์‰ฝ๊ณ  ๋น ๋ฅธ Go ์‹œ์ž‘ํ•˜๊ธฐ] #2.1 Methods part One [์ถœ์ฒ˜ - Nomad Coders] Method๋Š” function์ด๋ž‘ ๋น„์Šทํ•˜์ง€๋งŒ ์กฐ๊ธˆ ๋‹ค๋ฅด๋‹ค. // function func NewAccount(owner string) *Account { account := Account{owner: owner, balance: 0} return &account } // method func (a Account) Balance() int { // func ๋ฐ”๋กœ ๋’ค์— ๋ณ€์ˆ˜์™€ ๋ณ€์ˆ˜์˜ ํƒ€์ž…์„ ์ ์–ด์ค€๋‹ค. return a.balance } Go์—์„œ๋Š” ์•„๋ž˜์˜ (a Account) ๋ถ€๋ถ„์„ receiver๋ผ๊ณ  ํ•œ๋‹ค. receiver์„ ์ž‘์„ฑํ•  ๋•Œ๋Š” ๋ช‡ ๊ฐ€์ง€ ์ง€์ผœ์•ผํ•  ๊ทœ์น™์ด ์žˆ๋‹ค. ์œ„์˜ (a Account)๋ฅผ ๋”ฐ์„œ struct์˜ ์ฒซ ๊ธ€์ž๋ฅผ ๋”ฐ์„œ ์†Œ๋ฌธ์ž๋กœ ์ง€์–ด์•ผ ํ•œ๋‹ค. 2021. 11. 2.
๋ฐ˜์‘ํ˜•