Skip to content

Commit

Permalink
all: fix a lot of "unkeyed literal" vet warnings
Browse files Browse the repository at this point in the history
Reduces the output of 'go vet ./...' from 374 lines to 96. Many warnings
remain, but I have lost my patience for today.

Most of the changes below were automated, especially the single-line
mixins expressions. Unfortunately, many of the Traits structs required
manual copy-pasting.
  • Loading branch information
mvdan authored and warpfork committed Dec 4, 2020
1 parent f5f8b0d commit 354f194
Show file tree
Hide file tree
Showing 34 changed files with 356 additions and 356 deletions.
34 changes: 17 additions & 17 deletions adl/rot13adl/rot13node.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ func (*_R13String) ReprKind() ipld.ReprKind {
return ipld.ReprKind_String
}
func (*_R13String) LookupByString(string) (ipld.Node, error) {
return mixins.String{"rot13adl.R13String"}.LookupByString("")
return mixins.String{TypeName: "rot13adl.R13String"}.LookupByString("")
}
func (*_R13String) LookupByNode(ipld.Node) (ipld.Node, error) {
return mixins.String{"rot13adl.R13String"}.LookupByNode(nil)
return mixins.String{TypeName: "rot13adl.R13String"}.LookupByNode(nil)
}
func (*_R13String) LookupByIndex(idx int) (ipld.Node, error) {
return mixins.String{"rot13adl.R13String"}.LookupByIndex(0)
return mixins.String{TypeName: "rot13adl.R13String"}.LookupByIndex(0)
}
func (*_R13String) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
return mixins.String{"rot13adl.R13String"}.LookupBySegment(seg)
return mixins.String{TypeName: "rot13adl.R13String"}.LookupBySegment(seg)
}
func (*_R13String) MapIterator() ipld.MapIterator {
return nil
Expand All @@ -68,22 +68,22 @@ func (*_R13String) IsNull() bool {
return false
}
func (*_R13String) AsBool() (bool, error) {
return mixins.String{"rot13adl.R13String"}.AsBool()
return mixins.String{TypeName: "rot13adl.R13String"}.AsBool()
}
func (*_R13String) AsInt() (int, error) {
return mixins.String{"rot13adl.R13String"}.AsInt()
return mixins.String{TypeName: "rot13adl.R13String"}.AsInt()
}
func (*_R13String) AsFloat() (float64, error) {
return mixins.String{"rot13adl.R13String"}.AsFloat()
return mixins.String{TypeName: "rot13adl.R13String"}.AsFloat()
}
func (n *_R13String) AsString() (string, error) {
return n.synthesized, nil
}
func (*_R13String) AsBytes() ([]byte, error) {
return mixins.String{"rot13adl.R13String"}.AsBytes()
return mixins.String{TypeName: "rot13adl.R13String"}.AsBytes()
}
func (*_R13String) AsLink() (ipld.Link, error) {
return mixins.String{"rot13adl.R13String"}.AsLink()
return mixins.String{TypeName: "rot13adl.R13String"}.AsLink()
}
func (*_R13String) Prototype() ipld.NodePrototype {
return _R13String__Prototype{}
Expand Down Expand Up @@ -139,23 +139,23 @@ type _R13String__Assembler struct {
}

func (_R13String__Assembler) BeginMap(sizeHint int) (ipld.MapAssembler, error) {
return mixins.StringAssembler{"rot13adl.R13String"}.BeginMap(0)
return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.BeginMap(0)
}
func (_R13String__Assembler) BeginList(sizeHint int) (ipld.ListAssembler, error) {
return mixins.StringAssembler{"rot13adl.R13String"}.BeginList(0)
return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.BeginList(0)
}
func (na *_R13String__Assembler) AssignNull() error {
// REVIEW: unclear how this might compose with some other context (like a schema) which does allow nulls. Probably a wrapper type?
return mixins.StringAssembler{"rot13adl.R13String"}.AssignNull()
return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.AssignNull()
}
func (_R13String__Assembler) AssignBool(bool) error {
return mixins.StringAssembler{"rot13adl.R13String"}.AssignBool(false)
return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.AssignBool(false)
}
func (_R13String__Assembler) AssignInt(int) error {
return mixins.StringAssembler{"rot13adl.R13String"}.AssignInt(0)
return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.AssignInt(0)
}
func (_R13String__Assembler) AssignFloat(float64) error {
return mixins.StringAssembler{"rot13adl.R13String"}.AssignFloat(0)
return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.AssignFloat(0)
}
func (na *_R13String__Assembler) AssignString(v string) error {
switch na.m {
Expand All @@ -170,10 +170,10 @@ func (na *_R13String__Assembler) AssignString(v string) error {
return nil
}
func (_R13String__Assembler) AssignBytes([]byte) error {
return mixins.StringAssembler{"rot13adl.R13String"}.AssignBytes(nil)
return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.AssignBytes(nil)
}
func (_R13String__Assembler) AssignLink(ipld.Link) error {
return mixins.StringAssembler{"rot13adl.R13String"}.AssignLink(nil)
return mixins.StringAssembler{TypeName: "rot13adl.R13String"}.AssignLink(nil)
}
func (na *_R13String__Assembler) AssignNode(v ipld.Node) error {
if v.IsNull() {
Expand Down
34 changes: 17 additions & 17 deletions adl/rot13adl/rot13substrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ func (*_Substrate) ReprKind() ipld.ReprKind {
return ipld.ReprKind_String
}
func (*_Substrate) LookupByString(string) (ipld.Node, error) {
return mixins.String{"rot13adl.internal.Substrate"}.LookupByString("")
return mixins.String{TypeName: "rot13adl.internal.Substrate"}.LookupByString("")
}
func (*_Substrate) LookupByNode(ipld.Node) (ipld.Node, error) {
return mixins.String{"rot13adl.internal.Substrate"}.LookupByNode(nil)
return mixins.String{TypeName: "rot13adl.internal.Substrate"}.LookupByNode(nil)
}
func (*_Substrate) LookupByIndex(idx int) (ipld.Node, error) {
return mixins.String{"rot13adl.internal.Substrate"}.LookupByIndex(0)
return mixins.String{TypeName: "rot13adl.internal.Substrate"}.LookupByIndex(0)
}
func (*_Substrate) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
return mixins.String{"rot13adl.internal.Substrate"}.LookupBySegment(seg)
return mixins.String{TypeName: "rot13adl.internal.Substrate"}.LookupBySegment(seg)
}
func (*_Substrate) MapIterator() ipld.MapIterator {
return nil
Expand All @@ -61,22 +61,22 @@ func (*_Substrate) IsNull() bool {
return false
}
func (*_Substrate) AsBool() (bool, error) {
return mixins.String{"rot13adl.internal.Substrate"}.AsBool()
return mixins.String{TypeName: "rot13adl.internal.Substrate"}.AsBool()
}
func (*_Substrate) AsInt() (int, error) {
return mixins.String{"rot13adl.internal.Substrate"}.AsInt()
return mixins.String{TypeName: "rot13adl.internal.Substrate"}.AsInt()
}
func (*_Substrate) AsFloat() (float64, error) {
return mixins.String{"rot13adl.internal.Substrate"}.AsFloat()
return mixins.String{TypeName: "rot13adl.internal.Substrate"}.AsFloat()
}
func (n *_Substrate) AsString() (string, error) {
return n.raw, nil
}
func (*_Substrate) AsBytes() ([]byte, error) {
return mixins.String{"rot13adl.internal.Substrate"}.AsBytes()
return mixins.String{TypeName: "rot13adl.internal.Substrate"}.AsBytes()
}
func (*_Substrate) AsLink() (ipld.Link, error) {
return mixins.String{"rot13adl.internal.Substrate"}.AsLink()
return mixins.String{TypeName: "rot13adl.internal.Substrate"}.AsLink()
}
func (*_Substrate) Prototype() ipld.NodePrototype {
return _Substrate__Prototype{}
Expand Down Expand Up @@ -122,23 +122,23 @@ type _Substrate__Assembler struct {
}

func (_Substrate__Assembler) BeginMap(sizeHint int) (ipld.MapAssembler, error) {
return mixins.StringAssembler{"rot13adl.internal.Substrate"}.BeginMap(0)
return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.BeginMap(0)
}
func (_Substrate__Assembler) BeginList(sizeHint int) (ipld.ListAssembler, error) {
return mixins.StringAssembler{"rot13adl.internal.Substrate"}.BeginList(0)
return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.BeginList(0)
}
func (na *_Substrate__Assembler) AssignNull() error {
// REVIEW: unclear how this might compose with some other context (like a schema) which does allow nulls. Probably a wrapper type?
return mixins.StringAssembler{"rot13adl.internal.Substrate"}.AssignNull()
return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.AssignNull()
}
func (_Substrate__Assembler) AssignBool(bool) error {
return mixins.StringAssembler{"rot13adl.internal.Substrate"}.AssignBool(false)
return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.AssignBool(false)
}
func (_Substrate__Assembler) AssignInt(int) error {
return mixins.StringAssembler{"rot13adl.internal.Substrate"}.AssignInt(0)
return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.AssignInt(0)
}
func (_Substrate__Assembler) AssignFloat(float64) error {
return mixins.StringAssembler{"rot13adl.internal.Substrate"}.AssignFloat(0)
return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.AssignFloat(0)
}
func (na *_Substrate__Assembler) AssignString(v string) error {
switch na.m {
Expand All @@ -153,10 +153,10 @@ func (na *_Substrate__Assembler) AssignString(v string) error {
return nil
}
func (_Substrate__Assembler) AssignBytes([]byte) error {
return mixins.StringAssembler{"rot13adl.internal.Substrate"}.AssignBytes(nil)
return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.AssignBytes(nil)
}
func (_Substrate__Assembler) AssignLink(ipld.Link) error {
return mixins.StringAssembler{"rot13adl.internal.Substrate"}.AssignLink(nil)
return mixins.StringAssembler{TypeName: "rot13adl.internal.Substrate"}.AssignLink(nil)
}
func (na *_Substrate__Assembler) AssignNode(v ipld.Node) error {
if v.IsNull() {
Expand Down
34 changes: 17 additions & 17 deletions node/basic/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ func (plainBool) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Bool
}
func (plainBool) LookupByString(string) (ipld.Node, error) {
return mixins.Bool{"bool"}.LookupByString("")
return mixins.Bool{TypeName: "bool"}.LookupByString("")
}
func (plainBool) LookupByNode(key ipld.Node) (ipld.Node, error) {
return mixins.Bool{"bool"}.LookupByNode(nil)
return mixins.Bool{TypeName: "bool"}.LookupByNode(nil)
}
func (plainBool) LookupByIndex(idx int) (ipld.Node, error) {
return mixins.Bool{"bool"}.LookupByIndex(0)
return mixins.Bool{TypeName: "bool"}.LookupByIndex(0)
}
func (plainBool) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
return mixins.Bool{"bool"}.LookupBySegment(seg)
return mixins.Bool{TypeName: "bool"}.LookupBySegment(seg)
}
func (plainBool) MapIterator() ipld.MapIterator {
return nil
Expand All @@ -56,19 +56,19 @@ func (n plainBool) AsBool() (bool, error) {
return bool(n), nil
}
func (plainBool) AsInt() (int, error) {
return mixins.Bool{"bool"}.AsInt()
return mixins.Bool{TypeName: "bool"}.AsInt()
}
func (plainBool) AsFloat() (float64, error) {
return mixins.Bool{"bool"}.AsFloat()
return mixins.Bool{TypeName: "bool"}.AsFloat()
}
func (plainBool) AsString() (string, error) {
return mixins.Bool{"bool"}.AsString()
return mixins.Bool{TypeName: "bool"}.AsString()
}
func (plainBool) AsBytes() ([]byte, error) {
return mixins.Bool{"bool"}.AsBytes()
return mixins.Bool{TypeName: "bool"}.AsBytes()
}
func (plainBool) AsLink() (ipld.Link, error) {
return mixins.Bool{"bool"}.AsLink()
return mixins.Bool{TypeName: "bool"}.AsLink()
}
func (plainBool) Prototype() ipld.NodePrototype {
return Prototype__Bool{}
Expand Down Expand Up @@ -104,32 +104,32 @@ type plainBool__Assembler struct {
}

func (plainBool__Assembler) BeginMap(sizeHint int) (ipld.MapAssembler, error) {
return mixins.BoolAssembler{"bool"}.BeginMap(0)
return mixins.BoolAssembler{TypeName: "bool"}.BeginMap(0)
}
func (plainBool__Assembler) BeginList(sizeHint int) (ipld.ListAssembler, error) {
return mixins.BoolAssembler{"bool"}.BeginList(0)
return mixins.BoolAssembler{TypeName: "bool"}.BeginList(0)
}
func (plainBool__Assembler) AssignNull() error {
return mixins.BoolAssembler{"bool"}.AssignNull()
return mixins.BoolAssembler{TypeName: "bool"}.AssignNull()
}
func (na *plainBool__Assembler) AssignBool(v bool) error {
*na.w = plainBool(v)
return nil
}
func (plainBool__Assembler) AssignInt(int) error {
return mixins.BoolAssembler{"bool"}.AssignInt(0)
return mixins.BoolAssembler{TypeName: "bool"}.AssignInt(0)
}
func (plainBool__Assembler) AssignFloat(float64) error {
return mixins.BoolAssembler{"bool"}.AssignFloat(0)
return mixins.BoolAssembler{TypeName: "bool"}.AssignFloat(0)
}
func (plainBool__Assembler) AssignString(string) error {
return mixins.BoolAssembler{"bool"}.AssignString("")
return mixins.BoolAssembler{TypeName: "bool"}.AssignString("")
}
func (plainBool__Assembler) AssignBytes([]byte) error {
return mixins.BoolAssembler{"bool"}.AssignBytes(nil)
return mixins.BoolAssembler{TypeName: "bool"}.AssignBytes(nil)
}
func (plainBool__Assembler) AssignLink(ipld.Link) error {
return mixins.BoolAssembler{"bool"}.AssignLink(nil)
return mixins.BoolAssembler{TypeName: "bool"}.AssignLink(nil)
}
func (na *plainBool__Assembler) AssignNode(v ipld.Node) error {
if v2, err := v.AsBool(); err != nil {
Expand Down
34 changes: 17 additions & 17 deletions node/basic/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ func (plainBytes) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Bytes
}
func (plainBytes) LookupByString(string) (ipld.Node, error) {
return mixins.Bytes{"bytes"}.LookupByString("")
return mixins.Bytes{TypeName: "bytes"}.LookupByString("")
}
func (plainBytes) LookupByNode(key ipld.Node) (ipld.Node, error) {
return mixins.Bytes{"bytes"}.LookupByNode(nil)
return mixins.Bytes{TypeName: "bytes"}.LookupByNode(nil)
}
func (plainBytes) LookupByIndex(idx int) (ipld.Node, error) {
return mixins.Bytes{"bytes"}.LookupByIndex(0)
return mixins.Bytes{TypeName: "bytes"}.LookupByIndex(0)
}
func (plainBytes) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error) {
return mixins.Bytes{"bytes"}.LookupBySegment(seg)
return mixins.Bytes{TypeName: "bytes"}.LookupBySegment(seg)
}
func (plainBytes) MapIterator() ipld.MapIterator {
return nil
Expand All @@ -53,22 +53,22 @@ func (plainBytes) IsNull() bool {
return false
}
func (plainBytes) AsBool() (bool, error) {
return mixins.Bytes{"bytes"}.AsBool()
return mixins.Bytes{TypeName: "bytes"}.AsBool()
}
func (plainBytes) AsInt() (int, error) {
return mixins.Bytes{"bytes"}.AsInt()
return mixins.Bytes{TypeName: "bytes"}.AsInt()
}
func (plainBytes) AsFloat() (float64, error) {
return mixins.Bytes{"bytes"}.AsFloat()
return mixins.Bytes{TypeName: "bytes"}.AsFloat()
}
func (plainBytes) AsString() (string, error) {
return mixins.Bytes{"bytes"}.AsString()
return mixins.Bytes{TypeName: "bytes"}.AsString()
}
func (n plainBytes) AsBytes() ([]byte, error) {
return []byte(n), nil
}
func (plainBytes) AsLink() (ipld.Link, error) {
return mixins.Bytes{"bytes"}.AsLink()
return mixins.Bytes{TypeName: "bytes"}.AsLink()
}
func (plainBytes) Prototype() ipld.NodePrototype {
return Prototype__Bytes{}
Expand Down Expand Up @@ -104,32 +104,32 @@ type plainBytes__Assembler struct {
}

func (plainBytes__Assembler) BeginMap(sizeHint int) (ipld.MapAssembler, error) {
return mixins.BytesAssembler{"bytes"}.BeginMap(0)
return mixins.BytesAssembler{TypeName: "bytes"}.BeginMap(0)
}
func (plainBytes__Assembler) BeginList(sizeHint int) (ipld.ListAssembler, error) {
return mixins.BytesAssembler{"bytes"}.BeginList(0)
return mixins.BytesAssembler{TypeName: "bytes"}.BeginList(0)
}
func (plainBytes__Assembler) AssignNull() error {
return mixins.BytesAssembler{"bytes"}.AssignNull()
return mixins.BytesAssembler{TypeName: "bytes"}.AssignNull()
}
func (plainBytes__Assembler) AssignBool(bool) error {
return mixins.BytesAssembler{"bytes"}.AssignBool(false)
return mixins.BytesAssembler{TypeName: "bytes"}.AssignBool(false)
}
func (plainBytes__Assembler) AssignInt(int) error {
return mixins.BytesAssembler{"bytes"}.AssignInt(0)
return mixins.BytesAssembler{TypeName: "bytes"}.AssignInt(0)
}
func (plainBytes__Assembler) AssignFloat(float64) error {
return mixins.BytesAssembler{"bytes"}.AssignFloat(0)
return mixins.BytesAssembler{TypeName: "bytes"}.AssignFloat(0)
}
func (plainBytes__Assembler) AssignString(string) error {
return mixins.BytesAssembler{"bytes"}.AssignString("")
return mixins.BytesAssembler{TypeName: "bytes"}.AssignString("")
}
func (na *plainBytes__Assembler) AssignBytes(v []byte) error {
*na.w = plainBytes(v)
return nil
}
func (plainBytes__Assembler) AssignLink(ipld.Link) error {
return mixins.BytesAssembler{"bytes"}.AssignLink(nil)
return mixins.BytesAssembler{TypeName: "bytes"}.AssignLink(nil)
}
func (na *plainBytes__Assembler) AssignNode(v ipld.Node) error {
if v2, err := v.AsBytes(); err != nil {
Expand Down
Loading

0 comments on commit 354f194

Please sign in to comment.