Cleanup comments and whitespace (#471)
Run gofmt across the whole repo.
Remove lint-hint that was accidentally submitted in a prior PR.
diff --git a/proto/clone_test.go b/proto/clone_test.go
index ee26083..0d3b127 100644
--- a/proto/clone_test.go
+++ b/proto/clone_test.go
@@ -248,17 +248,17 @@
src: &pb.Communique{Union: &pb.Communique_Number{41}},
dst: &pb.Communique{Union: &pb.Communique_Name{"Bobby Tables"}},
want: &pb.Communique{Union: &pb.Communique_Number{41}},
- },
+ },
{ // Oneof nil is the same as not set.
src: &pb.Communique{},
dst: &pb.Communique{Union: &pb.Communique_Name{"Bobby Tables"}},
want: &pb.Communique{Union: &pb.Communique_Name{"Bobby Tables"}},
- },
+ },
{
src: &pb.Communique{Union: &pb.Communique_Number{1337}},
dst: &pb.Communique{},
want: &pb.Communique{Union: &pb.Communique_Number{1337}},
- },
+ },
{
src: &pb.Communique{Union: &pb.Communique_Col{pb.MyMessage_RED}},
dst: &pb.Communique{},
@@ -268,12 +268,12 @@
src: &pb.Communique{Union: &pb.Communique_Data{[]byte("hello")}},
dst: &pb.Communique{},
want: &pb.Communique{Union: &pb.Communique_Data{[]byte("hello")}},
- },
+ },
{
src: &pb.Communique{Union: &pb.Communique_Msg{&pb.Strings{BytesField: []byte{1, 2, 3}}}},
dst: &pb.Communique{},
want: &pb.Communique{Union: &pb.Communique_Msg{&pb.Strings{BytesField: []byte{1, 2, 3}}}},
- },
+ },
{
src: &pb.Communique{Union: &pb.Communique_Msg{}},
dst: &pb.Communique{},
diff --git a/proto/encode.go b/proto/encode.go
index ea0af27..c27d35f 100644
--- a/proto/encode.go
+++ b/proto/encode.go
@@ -133,7 +133,7 @@
return 8
case x < 1<<63:
return 9
-}
+ }
return 10
}
diff --git a/proto/extensions.go b/proto/extensions.go
index 95f0407..8c9818a 100644
--- a/proto/extensions.go
+++ b/proto/extensions.go
@@ -97,12 +97,12 @@
case extendableProto:
if isNilPtr(p) {
return nil, fmt.Errorf("proto: nil %T is not extendable", p)
- }
+ }
return p, nil
case extendableProtoV1:
if isNilPtr(p) {
return nil, fmt.Errorf("proto: nil %T is not extendable", p)
- }
+ }
return extensionAdapter{p}, nil
}
// Don't allocate a specific error containing %T:
diff --git a/proto/message_set.go b/proto/message_set.go
index 31782d0..3b6ca41 100644
--- a/proto/message_set.go
+++ b/proto/message_set.go
@@ -164,10 +164,7 @@
// This is an old-style extension map.
// Wrap it in a new-style XXX_InternalExtensions.
ie := XXX_InternalExtensions{
- p: &struct{
- //lint:ignore U1000 False positive - this
- //"unused" field is the dictated by the
- //anonymous struct type.
+ p: &struct {
mu sync.Mutex
extensionMap map[int32]Extension
}{
diff --git a/proto/pointer_reflect.go b/proto/pointer_reflect.go
index 07fb067..dea727c 100644
--- a/proto/pointer_reflect.go
+++ b/proto/pointer_reflect.go
@@ -66,7 +66,7 @@
// instead of reflect to implement the same (but faster) interface.
type pointer struct {
v reflect.Value
- }
+}
// toPointer converts an interface of pointer type to a pointer
// that points to the same target.
@@ -107,7 +107,7 @@
s.SetLen(n + 1)
} else {
s.Set(reflect.Append(s, reflect.Zero(s.Type().Elem())))
-}
+ }
return s.Index(n)
}
@@ -141,7 +141,7 @@
if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
// raw int32 type
return p.v.Elem().Interface().(*int32)
-}
+ }
// an enum
return p.v.Elem().Convert(int32PtrType).Interface().(*int32)
}
@@ -159,7 +159,7 @@
if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
// raw int32 type
return p.v.Elem().Interface().([]int32)
-}
+ }
// an enum
// Allocate a []int32, then assign []enum's values into it.
// Note: we can't convert []enum to []int32.
@@ -167,7 +167,7 @@
s := make([]int32, slice.Len())
for i := 0; i < slice.Len(); i++ {
s[i] = int32(slice.Index(i).Int())
-}
+ }
return s
}
@@ -178,23 +178,23 @@
// raw int32 type
p.v.Elem().Set(reflect.ValueOf(v))
return
- }
+ }
// an enum
// Allocate a []enum, then assign []int32's values into it.
// Note: we can't convert []enum to []int32.
slice := reflect.MakeSlice(p.v.Type().Elem(), len(v), cap(v))
for i, x := range v {
slice.Index(i).SetInt(int64(x))
- }
- p.v.Elem().Set(slice)
}
+ p.v.Elem().Set(slice)
+}
func (p pointer) appendInt32Slice(v int32) {
grow(p.v.Elem()).SetInt(int64(v))
}
func (p pointer) toUint64() *uint64 {
return p.v.Interface().(*uint64)
- }
+}
func (p pointer) toUint64Ptr() **uint64 {
return p.v.Interface().(**uint64)
}
@@ -206,13 +206,13 @@
}
func (p pointer) toUint32Ptr() **uint32 {
return p.v.Interface().(**uint32)
- }
+}
func (p pointer) toUint32Slice() *[]uint32 {
return p.v.Interface().(*[]uint32)
}
func (p pointer) toBool() *bool {
return p.v.Interface().(*bool)
- }
+}
func (p pointer) toBoolPtr() **bool {
return p.v.Interface().(**bool)
}
@@ -224,10 +224,10 @@
}
func (p pointer) toFloat64Ptr() **float64 {
return p.v.Interface().(**float64)
- }
+}
func (p pointer) toFloat64Slice() *[]float64 {
return p.v.Interface().(*[]float64)
- }
+}
func (p pointer) toFloat32() *float32 {
return p.v.Interface().(*float32)
}
@@ -236,7 +236,7 @@
}
func (p pointer) toFloat32Slice() *[]float32 {
return p.v.Interface().(*[]float32)
- }
+}
func (p pointer) toString() *string {
return p.v.Interface().(*string)
}
@@ -248,16 +248,16 @@
}
func (p pointer) toBytes() *[]byte {
return p.v.Interface().(*[]byte)
- }
+}
func (p pointer) toBytesSlice() *[][]byte {
return p.v.Interface().(*[][]byte)
- }
+}
func (p pointer) toExtensions() *XXX_InternalExtensions {
return p.v.Interface().(*XXX_InternalExtensions)
- }
+}
func (p pointer) toOldExtensions() *map[int32]Extension {
return p.v.Interface().(*map[int32]Extension)
- }
+}
func (p pointer) getPointer() pointer {
return pointer{v: p.v.Elem()}
}
@@ -278,7 +278,7 @@
s := make([]pointer, n)
for i := 0; i < n; i++ {
s[i] = pointer{v: p.v.Elem().Index(i)}
-}
+ }
return s
}
@@ -314,12 +314,12 @@
atomicLock.Lock()
defer atomicLock.Unlock()
return *p
- }
+}
func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) {
atomicLock.Lock()
defer atomicLock.Unlock()
*p = v
- }
+}
func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo {
atomicLock.Lock()
defer atomicLock.Unlock()
@@ -334,7 +334,7 @@
atomicLock.Lock()
defer atomicLock.Unlock()
return *p
- }
+}
func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) {
atomicLock.Lock()
defer atomicLock.Unlock()
diff --git a/proto/pointer_unsafe.go b/proto/pointer_unsafe.go
index 3eee81f..4197ae3 100644
--- a/proto/pointer_unsafe.go
+++ b/proto/pointer_unsafe.go
@@ -88,7 +88,7 @@
// The interface is of pointer type, thus it is a direct interface.
// The data word is the pointer data itself. We take its address.
return pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)}
-}
+ }
// The interface is not of pointer type. The data word is the pointer
// to the data.
return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]}
@@ -160,7 +160,7 @@
func (p pointer) toUint64() *uint64 {
return (*uint64)(p.p)
- }
+}
func (p pointer) toUint64Ptr() **uint64 {
return (**uint64)(p.p)
}
@@ -184,7 +184,7 @@
}
func (p pointer) toBoolSlice() *[]bool {
return (*[]bool)(p.p)
- }
+}
func (p pointer) toFloat64() *float64 {
return (*float64)(p.p)
}
diff --git a/proto/size_test.go b/proto/size_test.go
index 2c28a76..3abac41 100644
--- a/proto/size_test.go
+++ b/proto/size_test.go
@@ -60,7 +60,7 @@
}
// non-pointer custom message
-type nonptrMessage struct {}
+type nonptrMessage struct{}
func (m nonptrMessage) ProtoMessage() {}
func (m nonptrMessage) Reset() {}
diff --git a/proto/table_merge.go b/proto/table_merge.go
index abc3e4e..5525def 100644
--- a/proto/table_merge.go
+++ b/proto/table_merge.go
@@ -42,12 +42,12 @@
// Merge merges the src message into dst.
// This assumes that dst and src of the same type and are non-nil.
func (a *InternalMessageInfo) Merge(dst, src Message) {
- mi := atomicLoadMergeInfo(&a.merge)
- if mi == nil {
- mi = getMergeInfo(reflect.TypeOf(dst).Elem())
- atomicStoreMergeInfo(&a.merge, mi)
- }
- mi.merge(toPointer(&dst), toPointer(&src))
+ mi := atomicLoadMergeInfo(&a.merge)
+ if mi == nil {
+ mi = getMergeInfo(reflect.TypeOf(dst).Elem())
+ atomicStoreMergeInfo(&a.merge, mi)
+ }
+ mi.merge(toPointer(&dst), toPointer(&src))
}
type mergeInfo struct {
diff --git a/proto/text.go b/proto/text.go
index fab71bb..5016a55 100644
--- a/proto/text.go
+++ b/proto/text.go
@@ -561,7 +561,7 @@
v = v.Elem()
}
if err := tm.writeStruct(w, v); err != nil {
- return err
+ return err
}
}
w.unindent()
diff --git a/proto/text_parser.go b/proto/text_parser.go
index f8d066f..0685bae 100644
--- a/proto/text_parser.go
+++ b/proto/text_parser.go
@@ -305,7 +305,7 @@
i, err := strconv.ParseUint(ss, 16, 64)
if err != nil {
return "", "", fmt.Errorf(`\%c%s contains non-hexadecimal digits`, r, ss)
- }
+ }
if r == 'x' || r == 'X' {
return string([]byte{byte(i)}), s, nil
}