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

进入相同结构类型的结构?

I want a relationship between structs, example:

type A struct {
   X string
   Y int
   *A
}

It's possible this? And if it's possible, what is the right way to marshal and unmarshal to JSON this?

When i marshal this struct to JSON the field A is lost.

The code is correct, but the anonimous filed A is lost because have the same names as the struct. Solution:

type A struct {
   X string
   Y int
   Z *A
}

近期文章

  • Go编译错误:无法使用new(SimpleChaincode)
  • 如何在Golang中编写HTTP服务器无证书?
  • 使用正则表达式检测私有和公共RSA密钥
  • 从文档转到OS文件读取示例不起作用-声明
  • 安装gocql错误
  • 各位大神我tomcat起不来了,以下是报的错误
  • HTTP定时请求Golang
  • Go中切片内的对象
  • 去获取下载Hyperledger Fabric的不工作
  • golang中以下json数据的结构表示形式是什么?
  • Golang Reader接口实现,当您已有字节片缓冲区时
  • Golang如何从其余API JSON响应中获取特定密钥(从多结构)
  • 使用缓冲IO与使用Goroutine写入文件
  • 从函数类型获取结构
  • Go-如何将编组的json对象附加到文件
  • 关于Golang中的lambda函数/闭包的一些困惑
  • 使用`gopy`,如何正确地将[]字符串从Python传递到Go?
  • 如何索引AWS快照输出?
  • 使用结构成员代替结构本身
  • 去编译错误“未定义函数”

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华