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

nomad-coder12

[์‰ฝ๊ณ  ๋น ๋ฅธ Go ์‹œ์ž‘ํ•˜๊ธฐ] #1.7 Switch 2021. 10. 29.
[์‰ฝ๊ณ  ๋น ๋ฅธ Go ์‹œ์ž‘ํ•˜๊ธฐ] #1.5 for, range, ...args [์ถœ์ฒ˜ - Nomad Coders] loop Go์—์„  loop๋ฅผ for๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค. package main import "fmt" func superAdd(numbers ...int) int { for index, number := range numbers { // range๋Š” index๋ฅผ ์ค€๋‹ค. fmt.Println(index, number) } return 1 } func main() { superAdd(1, 2, 3, 4, 5, 6) } package main import "fmt" func superAdd(numbers ...int) int { for i := 0; i < len(numbers); i++ { fmt.Println(numbers[i]) } return 1 } func .. 2021. 10. 26.
[์‰ฝ๊ณ  ๋น ๋ฅธ Go ์‹œ์ž‘ํ•˜๊ธฐ] #1.4 Functions part Two [์ถœ์ฒ˜ - Nomad Coders] naked return function์˜ ๋˜ ๋‹ค๋ฅธ ๋ฉ‹์ง„ ๋ถ€๋ถ„์€ 'naked' return ์ด๋ผ ๋ถˆ๋ฆฌ๋Š” function ์ด๋‹ค. package main import ( "fmt" "strings" ) func lenAndUpper(name string) (length int, uppercase string) { length = len(name) uppercase = strings.ToUpper(name) return // naked return } func main() { totalLength, up := lenAndUpper("nico") fmt.Println(totalLength, up) } ์—ฌ๊ธฐ์„œ๋Š” Go๊ฐ€ ์ž๋™์ ์œผ๋กœ (length int, uppercase strin.. 2021. 10. 26.
[์‰ฝ๊ณ  ๋น ๋ฅธ Go ์‹œ์ž‘ํ•˜๊ธฐ] #1.3 Functions part One [์ถœ์ฒ˜ - Nomad Coders] function์˜ ๊ธฐ๋ณธ์ ์ธ Type์€ string ์ด๋‚˜ bool(Boolean) ์ด๋‹ค. ๊ทธ ์™ธ์— ์ˆซ์ž๋ฅผ ์œ„ํ•œ ์—ฌ๋Ÿฌ ์ข…๋ฅ˜์˜ Type๋“ค์ด ์žˆ๋‹ค. ์ด๋ฒˆ ๊ฐ•์˜์—์„  int๋ฅผ ์‚ฌ์šฉํ•ด ๋ณผ ๊ฒƒ์ด๋‹ค. ๋จผ์ € ๊ณฑ์…ˆ์„ ์œ„ํ•œ ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด ๋ณด์ž. Type ์ง€์ •์„ ์•ˆ ํ•ด์ค˜์„œ ์—๋Ÿฌ๊ฐ€ ๋œฌ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. TypeScript๋ฅผ ์‚ฌ์šฉํ•œ ๋ถ„๋“ค์ด๋ผ๋ฉด ์ต์ˆ™ํ•  ๊ฒƒ์ด๋‹ค. ์—๋Ÿฌ๊ฐ€ ๋œจ์ง€ ์•Š๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„  ์•„๋ž˜์™€ ๊ฐ™์ด ๋ฐ”๊ฟ”์ฃผ๋ฉด ๋œ๋‹ค. package main import "fmt" func multiply(a int, b int) int { // (a, b int) ๋กœ๋„ ๊ฐ€๋Šฅ return a * b } func main() { fmt.Println(multiply(2, 2)) } ๊ทธ๋ฆฌ๊ณ  return์˜ Type ๊ฐ’.. 2021. 10. 26.
[์‰ฝ๊ณ  ๋น ๋ฅธ Go ์‹œ์ž‘ํ•˜๊ธฐ] #1.2 Variables and Constants [์ถœ์ฒ˜ - Nomad Coders] Go์—์„œ ์ƒ์ˆ˜๋Š” JavaScript์˜ const์™€ ๊ฐ™๊ณ  ๋ณ€์ˆ˜๋Š” let ์œผ๋กœ ๋ณด๋ฉด ๋œ๋‹ค. ์ƒ์ˆ˜๋Š” ๋ณ€์ˆ˜์ง€๋งŒ ๊ฐ’์„ ๋ฐ”๊ฟ€ ์ˆ˜๋Š” ์—†๋‹ค. ๋ณ€์ˆ˜๋Š” ๋ง ๊ทธ๋Œ€๋กœ ๊ฐ’์„ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‹ค. Go๋Š” Type ์–ธ์–ด์ด๋‹ค. TypeScript์ฒ˜๋Ÿผ Type์„ ์ ์–ด ์ค˜์•ผ ํ•œ๋‹ค. package main func main() { const name string = "nico" } Type์„ ์ž˜๋ชป ์ง€์ •ํ•ด์ฃผ๋ฉด ์—๋Ÿฌ๊ฐ€ ๋œฌ๋‹ค. package main import "fmt" func main() { name := "nico" // ์ด๋ ‡๊ฒŒ ์„ ์–ธํ•˜๋ฉด Go๊ฐ€ ์•Œ์•„์„œ Type์„ ์ฐพ์•„ ์ค€๋‹ค. name = "lynn" fmt.Println(name) } ๋Œ€์‹  ์ด๋Ÿฐ ์ถ•์•ฝํ˜•์€ func ์•ˆ์—์„œ๋งŒ ๊ฐ€๋Šฅํ•˜๊ณ  ๋ณ€์ˆ˜์—๋งŒ ์ ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค... 2021. 10. 26.
[์‰ฝ๊ณ  ๋น ๋ฅธ Go ์‹œ์ž‘ํ•˜๊ธฐ] #1.0 Main Package [์ถœ์ฒ˜ - Nomad Coders] package main // Go์—์„œ๋Š” ์–ด๋–ค ํŒจํ‚ค์ง€๋ฅผ ์‚ฌ์šฉํ•˜๋Š”์ง€ ์ž‘์„ฑํ•ด์ค˜์•ผ ํ•œ๋‹ค. import "fmt" // Go์—์„œ๋Š” "fmt"๋ผ๋Š” ๊ธฐ๋ณธ์ ์ธ formatting package๋ฅผ ์ œ๊ณตํ•ด ์ค€๋‹ค. func main() { fmt.Println("Hello world!") // stdout ์œผ๋กœ ํ‘œ์ค€ ๋ฌธ์ž์—ด ์ถœ๋ ฅ์„ ์ œ๊ณตํ•˜๋Š” ํ•จ์ˆ˜ } 2021. 10. 26.
๋ฐ˜์‘ํ˜•