105 lines
1.7 KiB
Go
Raw Normal View History

2019-09-27 18:47:42 +08:00
package main
// MyStruct 介绍
type MyStruct struct {
Value int
Key string
Do func(
a int,
2019-09-29 18:48:37 +08:00
b struct {
A, B int
C string
})
2019-09-27 18:47:42 +08:00
S struct{ A int }
}
2019-09-29 18:48:37 +08:00
type MyStruct2 struct {
Value int
Key string
Do func(
a int,
b struct {
A, B int
C string
})
S struct{ A struct{ C interface{} } }
}
// DoFunc 非常丑陋
func DoFunc(a func(
a int,
b struct {
A, B int
C string
})) {
return
}
2019-09-27 18:47:42 +08:00
// ExStruct 升级
type ExStruct struct {
ChildStruct struct {
2019-10-08 18:22:24 +08:00
A int
B interface{}
girl string
boy int
2019-09-27 18:47:42 +08:00
}
2019-10-08 18:22:24 +08:00
C string
D func(a int, b string)
child string
}
// GetChildStructBoy Get return boy int
func (es *ExStruct) GetChildStructBoy() int {
return es.ChildStruct.boy
}
// SetChildStructBoy Set boy int
func (es *ExStruct) SetChildStructBoy(boy int) {
es.ChildStruct.boy = boy
}
// GetChildStructGirl Get return girl string
func (es *ExStruct) GetChildStructGirl() string {
return es.ChildStruct.girl
2019-10-12 18:29:34 +08:00
2019-10-08 18:22:24 +08:00
}
// SetChildStructGirl Set girl string
func (es *ExStruct) SetChildStructGirl(girl string) {
es.ChildStruct.girl = girl
}
// GetChildStructGirl
// GetChildStructB Get return B interface{}
func (es *ExStruct) GetChildStructB() interface{} {
return es.ChildStruct.B
}
// SetChildStructB Set B interface{}
func (es *ExStruct) SetChildStructB(B interface{}) {
es.ChildStruct.B = B
2019-09-27 18:47:42 +08:00
}
// SetChildStructA set
2019-10-08 18:22:24 +08:00
func (es *ExStruct) SetChildStructA(a int) {
es.ChildStruct.A = a
2019-09-27 18:47:42 +08:00
}
2019-09-30 18:38:01 +08:00
// GetChildStructA get
2019-10-08 18:22:24 +08:00
func (es *ExStruct) GetChildStructA() int {
return es.ChildStruct.A
2019-09-30 18:38:01 +08:00
}
// GetC get
2019-10-08 18:22:24 +08:00
func (es *ExStruct) GetC(a int) {
es.ChildStruct.A = a
2019-09-30 18:38:01 +08:00
}
2019-09-27 18:47:42 +08:00
func main() {
a := ExStruct{}
2019-09-29 18:48:37 +08:00
b := MyStruct{}
c := MyStruct2{}
println(a, b, c)
2019-09-27 18:47:42 +08:00
}