Files
go-study/main/p1.go
2024-08-01 23:40:06 +08:00

35 lines
429 B
Go

package main
import "fmt"
type Student struct {
Name string
}
// 函数
func mthod(s Student) {
fmt.Println(s.Name)
}
func mthod1(s *Student) {
fmt.Println((*s).Name)
}
func (s *Student) test02() {
fmt.Println(s.Name)
}
func main() {
var stu = Student{"笑傲"}
mthod(stu)
mthod1(&stu)
(&stu).test02()
var s = Student{
Name: "xio",
}
fmt.Println(s)
var s3 *student = &student{
age: 19,
}
fmt.Println(s3)
}