浏览 189
分享
Use Field Names to initialize Structs
You should almost always specify field names when initializing structs. This isnow enforced by go vet
.
Bad | Good |
---|---|
|
|
Exception: Field names may be omitted in test tables when there are 3 orfewer fields.
- tests := []struct{
- op Operation
- want string
- }{
- {Add, "add"},
- {Subtract, "subtract"},
- }
评论列表