IT
go 스트럭트
thesse
2021. 5. 13. 14:31
300x250
반응형
go에는 클래스나 오브젝트가 없는 대신 struct를 사용함
type person struct {
name string
age int
favFood []string
}
func main() {
// 이렇게 그냥 값만 집어넣어도 되고
thesse := person{"thesse", 28, []string{"aa", "bb"}}
// 키밸류로 넣어도 됨
thesse := person{name:"thesse", age:28, favFood: []string{"aa", "bb"}}
fmt.Println(thesse)
fmt.Println(thesse.favFood[1])
}
300x250
반응형