Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues that cause linters to complain. #182

Merged
merged 11 commits into from
Oct 28, 2021
4 changes: 2 additions & 2 deletions address.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ const maxSegmentSize Size = 1<<32 - 8
func maxAllocSize() Size {
if maxInt == 0x7fffffff {
return Size(0x7ffffff8)
} else {
return maxSegmentSize
}

return maxSegmentSize
}

// DataOffset is an offset in bytes from the beginning of a struct's
Expand Down
6 changes: 3 additions & 3 deletions capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func NewInterface(s *Segment, cap CapabilityID) Interface {
}

// ToPtr converts the interface to a generic pointer.
func (p Interface) ToPtr() Ptr {
func (i Interface) ToPtr() Ptr {
return Ptr{
seg: p.seg,
lenOrCap: uint32(p.cap),
seg: i.seg,
lenOrCap: uint32(i.cap),
flags: interfacePtrFlag,
}
}
Expand Down
33 changes: 16 additions & 17 deletions capnpc-go/capnpc-go.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,8 @@ func (g *generator) Value(rel *node, t schema.Type, v schema.Value) (string, err
case schema.Type_Which_bool:
if v.Bool() {
return "true", nil
} else {
return "false", nil
}
return "false", nil

case schema.Type_Which_uint8, schema.Type_Which_uint16, schema.Type_Which_uint32, schema.Type_Which_uint64:
return fmt.Sprintf("uint%d(%d)", intbits(t.Which()), uintValue(v)), nil
Expand Down Expand Up @@ -661,21 +660,21 @@ var (
}
staticListTypeRefs = map[schema.Type_Which]typeRef{
// TODO(light): omitting newfunc since it doesn't have a similar type signature (no errors).
schema.Type_Which_void: typeRef{name: "VoidList", imp: capnpImportSpec},

schema.Type_Which_bool: typeRef{name: "BitList", newfunc: "NewBitList", imp: capnpImportSpec},
schema.Type_Which_int8: typeRef{name: "Int8List", newfunc: "NewInt8List", imp: capnpImportSpec},
schema.Type_Which_uint8: typeRef{name: "UInt8List", newfunc: "NewUInt8List", imp: capnpImportSpec},
schema.Type_Which_int16: typeRef{name: "Int16List", newfunc: "NewInt16List", imp: capnpImportSpec},
schema.Type_Which_uint16: typeRef{name: "UInt16List", newfunc: "NewUInt16List", imp: capnpImportSpec},
schema.Type_Which_int32: typeRef{name: "Int32List", newfunc: "NewInt32List", imp: capnpImportSpec},
schema.Type_Which_uint32: typeRef{name: "UInt32List", newfunc: "NewUInt32List", imp: capnpImportSpec},
schema.Type_Which_int64: typeRef{name: "Int64List", newfunc: "NewInt64List", imp: capnpImportSpec},
schema.Type_Which_uint64: typeRef{name: "UInt64List", newfunc: "NewUInt64List", imp: capnpImportSpec},
schema.Type_Which_float32: typeRef{name: "Float32List", newfunc: "NewFloat32List", imp: capnpImportSpec},
schema.Type_Which_float64: typeRef{name: "Float64List", newfunc: "NewFloat64List", imp: capnpImportSpec},
schema.Type_Which_text: typeRef{name: "TextList", newfunc: "NewTextList", imp: capnpImportSpec},
schema.Type_Which_data: typeRef{name: "DataList", newfunc: "NewDataList", imp: capnpImportSpec},
schema.Type_Which_void: {name: "VoidList", imp: capnpImportSpec},

schema.Type_Which_bool: {name: "BitList", newfunc: "NewBitList", imp: capnpImportSpec},
schema.Type_Which_int8: {name: "Int8List", newfunc: "NewInt8List", imp: capnpImportSpec},
schema.Type_Which_uint8: {name: "UInt8List", newfunc: "NewUInt8List", imp: capnpImportSpec},
schema.Type_Which_int16: {name: "Int16List", newfunc: "NewInt16List", imp: capnpImportSpec},
schema.Type_Which_uint16: {name: "UInt16List", newfunc: "NewUInt16List", imp: capnpImportSpec},
schema.Type_Which_int32: {name: "Int32List", newfunc: "NewInt32List", imp: capnpImportSpec},
schema.Type_Which_uint32: {name: "UInt32List", newfunc: "NewUInt32List", imp: capnpImportSpec},
schema.Type_Which_int64: {name: "Int64List", newfunc: "NewInt64List", imp: capnpImportSpec},
schema.Type_Which_uint64: {name: "UInt64List", newfunc: "NewUInt64List", imp: capnpImportSpec},
schema.Type_Which_float32: {name: "Float32List", newfunc: "NewFloat32List", imp: capnpImportSpec},
schema.Type_Which_float64: {name: "Float64List", newfunc: "NewFloat64List", imp: capnpImportSpec},
schema.Type_Which_text: {name: "TextList", newfunc: "NewTextList", imp: capnpImportSpec},
schema.Type_Which_data: {name: "DataList", newfunc: "NewDataList", imp: capnpImportSpec},
}
)

Expand Down
2 changes: 2 additions & 0 deletions internal/cmd/mktemplates/mktemplates.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//go:build mktemplates
// +build mktemplates

// Build tag so that users who run `go get capnproto.org/go/capnp/v3/...` don't install this command.
// cd internal/cmd/mktemplates && go build -tags=mktemplates

Expand Down
1 change: 1 addition & 0 deletions internal/fuzztest/fuzztest.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build gofuzz
// +build gofuzz

// Fuzz test harness. To run:
Expand Down
1 change: 1 addition & 0 deletions internal/nodemap/nodemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func (m *Map) registry() *schemas.Registry {
return &schemas.DefaultRegistry
}

// UseRegistry assigns 'reg' to 'm' and initializes the nodes map.
func (m *Map) UseRegistry(reg *schemas.Registry) {
m.reg = reg
m.nodes = make(map[uint64]schema.Node)
Expand Down
1 change: 1 addition & 0 deletions internal/packed/discard.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.5
// +build go1.5

package packed
Expand Down
1 change: 1 addition & 0 deletions internal/packed/discard_go14.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !go1.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library can't possibly still work on Go 1.4, maybe we should just delete some of these? (can be a separate pr, if you want to take it on).

Copy link
Collaborator Author

@lthibault lthibault Oct 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's def nuke it. So we should just drop these tags altogether?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think so.

// +build !go1.5

package packed
Expand Down
1 change: 1 addition & 0 deletions internal/packed/fuzz.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build gofuzz
// +build gofuzz

// Fuzz test harness. To run:
Expand Down
4 changes: 2 additions & 2 deletions list.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func NewTextList(s *Segment, n int32) (TextList, error) {
if err != nil {
return TextList{}, err
}
return TextList{pl.List}, nil
return TextList(pl), nil
}

// At returns the i'th string in the list.
Expand Down Expand Up @@ -426,7 +426,7 @@ func NewDataList(s *Segment, n int32) (DataList, error) {
if err != nil {
return DataList{}, err
}
return DataList{pl.List}, nil
return DataList(pl), nil
}

// At returns the i'th data in the list.
Expand Down
1 change: 1 addition & 0 deletions message_go18.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.8
// +build go1.8

package capnp
Expand Down
1 change: 1 addition & 0 deletions message_other.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !go1.8
// +build !go1.8

package capnp
Expand Down
1 change: 1 addition & 0 deletions msgp_bench_gen_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build msgpbench
// +build msgpbench

package capnp_test
Expand Down
2 changes: 2 additions & 0 deletions msgp_bench_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//go:build msgpbench
// +build msgpbench

//go:generate msgp -tests=false -o msgp_bench_gen_test.go
//msgp:Tuple Event

Expand Down
4 changes: 2 additions & 2 deletions pogs/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ func (ins *inserter) insertField(s capnp.Struct, f schema.Field, val reflect.Val
}
if val.Kind() == reflect.String {
return s.SetText(off, val.String())
} else {
return s.SetTextFromBytes(off, val.Bytes())
}
return s.SetTextFromBytes(off, val.Bytes())

case schema.Type_Which_data:
b := val.Bytes()
if b == nil && !isEmptyValue(dv) {
Expand Down
2 changes: 1 addition & 1 deletion pointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (p Ptr) text() (b []byte, ok bool) {
// Text must be null-terminated.
return nil, false
}
return b[:len(b)-1 : len(b)], true
return b[: len(b)-1 : len(b)], true
}

// Data attempts to convert p into Data, returning nil if p is not a
Expand Down
2 changes: 1 addition & 1 deletion rpc/answer.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (ans *answer) sendException(e error) releaseList {
if ans.flags&finishReceived == 0 {
return nil
}
// destory will never return an error because sendException does
// destroy will never return an error because sendException does
// create any exports.
rl, _ := ans.destroy()
ans.c.mu.Unlock()
Expand Down
5 changes: 2 additions & 3 deletions rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ type Options struct {
AbortTimeout time.Duration
}

// A type that implements ErrorReporter can receive errors from a Conn.
// ReportError should be quick to return and should not use the Conn
// that it is attached to.
// ErrorReporter can receive errors from a Conn. ReportError should be quick
// to return and should not use the Conn that it is attached to.
type ErrorReporter interface {
ReportError(error)
}
Expand Down
3 changes: 2 additions & 1 deletion rpc/transport_go19_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build go1.9
//go:build go1.9
// +build go1.9

package rpc_test

Expand Down