So I can have
struct {
int
x []int
}
However,
struct {
int
[]int
}
will result in a syntax error: unexpected [, expecting }
. Is there a way of having unnamed arrays in structs in Go? If so, what's the correct syntax?
So I can have
struct {
int
x []int
}
However,
struct {
int
[]int
}
will result in a syntax error: unexpected [, expecting }
. Is there a way of having unnamed arrays in structs in Go? If so, what's the correct syntax?
No, the type of an anonymous field must be a type name or a pointer to a type name. You could declare a new type name that is the same as an array type, and then it would work, but it wouldn't be exactly the same.