Reputation: 102207
I found the struct
is defined in the source code of a package like this:
var resp struct {
CreateTodo struct{ ID string }
}
I always define the struct like this:
type resp struct {
CreateTodo struct{ ID string }
}
I have never seen this. After searching, I only found a doc about it. But there is no explanation of its meaning.
So, what's the difference between type xxx struct {}
and var xxx struct {}
? When and how should I use var xxx struct {}
? Thanks.
Upvotes: 3
Views: 1392
Reputation: 43728
This declares a variable resp
whose type is the (anonymous) struct.
Upvotes: 3