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.
28 lines
364 B
28 lines
364 B
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// 具体结构体
|
|
type Employee struct {
|
|
firstName, lastName string
|
|
age, salary int
|
|
}
|
|
|
|
func main() {
|
|
emp1 := Employee{}
|
|
fmt.Println(emp1)
|
|
|
|
// 匿名结构体
|
|
emp2 := struct{
|
|
firstName, lastName string
|
|
age, salary int
|
|
}{
|
|
firstName:"wanshaobo",
|
|
lastName: "wan",
|
|
age: 24,
|
|
salary: 1500,
|
|
}
|
|
fmt.Println(emp2);
|
|
} |