You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
352 B
25 lines
352 B
3 years ago
|
package main
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
type student struct {
|
||
|
name string
|
||
|
age int
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
m := make(map[string]*student)
|
||
|
stus := []student{
|
||
|
{name: "小王子", age: 18},
|
||
|
{name: "娜扎", age: 23},
|
||
|
{name: "大王八", age: 9000},
|
||
|
}
|
||
|
|
||
|
for _, stu := range stus {
|
||
|
m[stu.name] = &stu
|
||
|
}
|
||
|
for k, v := range m {
|
||
|
fmt.Println(k, "=>", v.name)
|
||
|
}
|
||
|
}
|