77 lines
1.0 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{} } }
}
2019-10-14 02:45:38 +08:00
// SetSAC Set C interface{}
func (ms *MyStruct2) SetSAC(C interface{}) {
ms.S.A.C = C
}
// GetKey Get return Key string
func (ms *MyStruct2) GetKey() string {
return ms.Key
}
// SetKey Set Key string
func (ms *MyStruct2) SetKey(Key string) {
ms.Key = Key
}
// GetValue Get return Value int
func (ms *MyStruct2) GetValue() int {
return ms.Value
}
2019-10-14 10:45:25 +08:00
// DoFunc 非常丑陋的兼容
2019-09-29 18:48:37 +08:00
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-14 10:45:25 +08:00
age int
Height interface{}
girl string
boy int
2019-09-27 18:47:42 +08:00
}
2019-10-14 10:45:25 +08:00
Age string
Do func(a int, b string)
2019-10-08 18:22:24 +08:00
child string
}
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
}