Go
-
[Go] function을 공부해보자Go 2021. 12. 27. 22:53
package main import ( "fmt" "strings" ) func main(){ fmt.Println(multiplay(2,2)) length, UPPER := lenAndUpper("kim") // _ 넣으면 무시 가능 leng, _ := lenAndUpper("lee") fmt.Println(length, UPPER, leng) => 3, KIM, 3 repeatMe("kim", "lee", "park") => [kim lee park] } // arg에 대한 type을 지정해 준다 다음은 return에 대한 type func multiplay(a int,b int) int { return a * b } // arg에 대한 type 지정후 reuturn 값들에 대한 type 지정, 여러..
-
Go를 배워보자Go 2021. 12. 27. 22:12
mac local의 user/go/src/github.com/{username} 안에 있는 폴더에다가 프로젝트폴더 만들자 왜냐하면 고는 원래 그렇게 쓰는 거다 main.go라고 파일명을 만들어야 실행 가능 이놈만 컴파일 한다 const = 상수 값 못바꿈 const name string = "kim" var = 변수 값 바꿀수 있음 var name string = "kim" name = "insub" := type 설정 안해줘도됨 함수 내에서만 사용가능하고 당연하게도 var에만 사용가능 var name string = "kim" name := "insub"