go - `type foo struct` 和 `type foo []struct` 之间的区别

标签 go types

这些结构之间的主要区别是什么?

type foo struct {
    Name string `json:"name"`
}

type foo []struct {
    Name string `json:"name"`
}

最佳答案

type foo1 struct {
    Name string `json:"name"`
}

type foo2 []struct {
    Name string `json:"name"`
}

简单理解为

type foo2 []foo1 

关于go - `type foo struct` 和 `type foo []struct` 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53361099/

相关文章:

go - 功能实现接口(interface)

Go errors : Is() and As() claim to be recursive, 是否有实现错误接口(interface)并支持此递归的任何类型 - 无错误?

linux - 如何将我的 Go 程序从 Mac OS X 交叉编译到 Ubuntu 64 位

pointers - 为什么 Go 标准库更喜欢指针接收器?

types - 重构模块会从编译器创建不同类型的请求?

iOS - 文件输入 - 变量类型转换问题

haskell - 如何检查我正在处理 Haskell 中的列表?

windows - 有没有办法为 "DIR"命令转义空格

c++ - 如何写一个无符号的短整型文字?

java - 为什么调用静态方法时用括号包裹类型是非法的?