Go基础语法
Go基础语法
二楼后座。
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
go interface{}类型转换为数组或者切片
func Test_toInt64Slice(t *testing.T) { res, err := toInt64Slice([]int64{1}) fmt.Println(err, res)}func toInt64Slice(actual interface{}) ([]int64, error) { var res []int64 value := reflect.ValueOf(actual) if value.Kind() != reflect.Slice && v原创 2021-11-30 15:43:18 · 4862 阅读 · 0 评论 -
Go语言面向对象编程
封装type Person struct { Name string age int}Name首字母大写,相当于Java中public修饰age首字母小写,相当于Java中private修饰继承与其说继承,不如称为组合,通过组合的方式实现继承的效果type Person struct{ Name string}type Teacher struct{ person Person}多态go的多态通过实现接口实现package mainimport "fmt"typ原创 2021-07-05 17:37:31 · 130 阅读 · 0 评论
分享