package main import (
"fmt"
) const (
URL = "http://www.163.com"
UID = "admin"
TOKEN = ""
) type Ren struct {
Phone string
} type Student struct {
Ren
Name string
Age int
}
type Teacher struct {
Ren
Name string
Age int
} func main() {
a := Student{
Ren: Ren{Phone: ""},
Name: "test1",
Age: ,
}
b := Student{
Ren: Ren{Phone: ""},
Name: "kkk2",
Age: ,
} fmt.Println(a, b)
}
结构定义方法
type Teacher struct {
Name string
Age int
} func main() {
c := Teacher{}
c.Say()
} func (t Teacher) Say() {
fmt.Println("say test test!")
}