package main
type person struct {
name string
age int
}
func main() {
nico := person{name : "nico", age: 12} // 순서대로 person{"nico",12}도 가능
}
package main
import "fmt"
type person struct {
name string
age int
}
func (p person) sayHello(){
fmt.Printf("Hello! My name is %s and I'm %d", p.name, p.age)
}
func main() {
nico := person{name : "nico", age: 12}
nico.sayHello()
}
강의 출처 : 노마드코더(https://nomadcoders.co)
[Nomad Coin] Blockchain - #4.0 Introduction (0) | 2022.07.13 |
---|---|
[Nomad Coin] Tour of Go - #3.7 Structs with Pointers (0) | 2022.07.11 |
[Nomad Coin] Tour of Go - #3.5 Pointers (0) | 2022.07.10 |
[Nomad Coin] Tour of Go - #3.4 Slices and Arrays (0) | 2022.07.10 |
[Nomad Coin] Tour of Go - #3.3 fmt (0) | 2022.07.10 |
댓글 영역