2022-11-13:以下go语言代码中,如何获取结 2022-11-13:以下go语言代码中,如何获取结构体列表以及结构体内的指针方法列表?以下代码应该返回{"S1":["M1","M2"],"S2":[],"S3":["M1","M3"]},顺序不限。S1的M3方法不是指针方法,S3的M2方法也不是指针方法,所以不能输出。
type S1 struct{}
func (this *S1) M1() {}
func (this *S1) M2() {}
func (this S1) M3() {}
type S2 struct{}
type S3 struct{}
func (this *S3) M1() {}
func (this S3) M2() {}
func (this *S3) M3() {}
#福大大架构师每日一题# https://t.cn/A6oeheZB https://t.cn/8FlsDfZ
type S1 struct{}
func (this *S1) M1() {}
func (this *S1) M2() {}
func (this S1) M3() {}
type S2 struct{}
type S3 struct{}
func (this *S3) M1() {}
func (this S3) M2() {}
func (this *S3) M3() {}
#福大大架构师每日一题# https://t.cn/A6oeheZB https://t.cn/8FlsDfZ
2022-11-08:以下go语言代码输出什么?A:2 2022-11-08:以下go语言代码输出什么?A:2;B:编译错误;C:运行 panic。
package main
import "fmt"
func main() {
a := []int{5}
for range a {
a = append(a, 1)
}
fmt.Println(len(a))
}
#福大大架构师每日一题# https://t.cn/A6ouUe19 https://t.cn/8FlsDfZ
package main
import "fmt"
func main() {
a := []int{5}
for range a {
a = append(a, 1)
}
fmt.Println(len(a))
}
#福大大架构师每日一题# https://t.cn/A6ouUe19 https://t.cn/8FlsDfZ
2022-11-02:以下go语言代码输出什么?A: 2022-11-02:以下go语言代码输出什么?A:编译错误;B:apple;C:ant;D:panic。
package main
import "fmt"
func main() {
pairs := [][2]string{
{"a", "apple"},
{"a", "ant"},
{"b", "bee"},
}
m := map[string]string{
pairs[0][0]: pairs[0][1],
pairs[1][0]: pairs[1][1],
pairs[2][0]: pairs[2][1],
}
fmt.Println(m["a"])
}
#福大大架构师每日一题# https://t.cn/A6oYLnoD https://t.cn/RU70xRg
package main
import "fmt"
func main() {
pairs := [][2]string{
{"a", "apple"},
{"a", "ant"},
{"b", "bee"},
}
m := map[string]string{
pairs[0][0]: pairs[0][1],
pairs[1][0]: pairs[1][1],
pairs[2][0]: pairs[2][1],
}
fmt.Println(m["a"])
}
#福大大架构师每日一题# https://t.cn/A6oYLnoD https://t.cn/RU70xRg
✋热门推荐