我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

在go中声明泛型类型对象

Is there a generic type Object in golang similar to other languages that can be assigned any kind of payload?

type Foo struct {
    data object
}

All Go types implement the empty interface interface{}.

type Foo struct {
   data interface{}
}

The empty interface is covered in A Tour of Go, The Laws of Reflection and the specification.

近期文章

  • 如何将字符串切片转换为符文切片
  • 在Go中处理来自base64解码的错误
  • Hyperledger自定义Chaincode部署错误
  • defer语句在哪里实现?
  • 使用Golang生成6位数的验证码?
  • 同时,如何管理价值/状态并避免竞争状况
  • 如何查看嵌套Go依赖的完整依赖树
  • Godoc中的图片?
  • 转到h2数据库
  • 为什么不读/写其内容的结构方法仍然引起竞争?
  • Golang os.Open没有这样的文件或目录错误
  • smpp generic_ nack message length is invalid
  • Golang模板:上下文是什么?
  • 如何从Golang中的SQL解析* time.Time?
  • “获取”如何了解与远程存储库一起使用的版本控制系统?
  • 在Go Web服务器上使用外部CSS文件
  • golang,结合两种方法具有相同的内容
  • 杭电oj2022的解答,感谢?
  • 兄弟萌,这样写哪错了???
  • 在Perl6中有与Go goroutines等效的东西吗?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华