staticcheck: Fix unused fields
The embedded `nocmp` field and other similar fields are unused in tests and the rest of our code. We can get the effect of `nocmp` without embedding the fields by using `_ nocmp` as a field.
This commit is contained in:
2
bool.go
2
bool.go
@@ -28,7 +28,7 @@ import (
|
||||
|
||||
// Bool is an atomic type-safe wrapper for bool values.
|
||||
type Bool struct {
|
||||
nocmp // disallow non-atomic comparison
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v Uint32
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
// Duration is an atomic type-safe wrapper for time.Duration values.
|
||||
type Duration struct {
|
||||
nocmp // disallow non-atomic comparison
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v Int64
|
||||
}
|
||||
|
||||
2
error.go
2
error.go
@@ -24,7 +24,7 @@ package atomic
|
||||
|
||||
// Error is an atomic type-safe wrapper for error values.
|
||||
type Error struct {
|
||||
nocmp // disallow non-atomic comparison
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v Value
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
// Float64 is an atomic type-safe wrapper for float64 values.
|
||||
type Float64 struct {
|
||||
nocmp // disallow non-atomic comparison
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v Uint64
|
||||
}
|
||||
|
||||
2
int32.go
2
int32.go
@@ -30,7 +30,7 @@ import (
|
||||
|
||||
// Int32 is an atomic wrapper around int32.
|
||||
type Int32 struct {
|
||||
nocmp // disallow non-atomic comparison
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v int32
|
||||
}
|
||||
|
||||
2
int64.go
2
int64.go
@@ -30,7 +30,7 @@ import (
|
||||
|
||||
// Int64 is an atomic wrapper around int64.
|
||||
type Int64 struct {
|
||||
nocmp // disallow non-atomic comparison
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v int64
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ import (
|
||||
|
||||
// {{ .Name }} is an atomic wrapper around {{ .Wrapped }}.
|
||||
type {{ .Name }} struct {
|
||||
nocmp // disallow non-atomic comparison
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v {{ .Wrapped }}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ import (
|
||||
|
||||
// {{ .Name }} is an atomic type-safe wrapper for {{ .Type }} values.
|
||||
type {{ .Name }} struct{
|
||||
nocmp // disallow non-atomic comparison
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v {{ .Wrapped }}
|
||||
}
|
||||
|
||||
@@ -77,14 +77,13 @@ func TestNocmpComparability(t *testing.T) {
|
||||
|
||||
// nocmp must not add to the size of a struct in-memory.
|
||||
func TestNocmpSize(t *testing.T) {
|
||||
type x struct{ i int }
|
||||
type x struct{ _ int }
|
||||
|
||||
before := reflect.TypeOf(x{}).Size()
|
||||
|
||||
type y struct {
|
||||
nocmp
|
||||
|
||||
x x
|
||||
_ nocmp
|
||||
_ x
|
||||
}
|
||||
|
||||
after := reflect.TypeOf(y{}).Size()
|
||||
@@ -100,7 +99,7 @@ func TestNocmpSize(t *testing.T) {
|
||||
// var x atomic.Int32
|
||||
// x = atomic.NewInt32(1)
|
||||
func TestNocmpCopy(t *testing.T) {
|
||||
type foo struct{ nocmp }
|
||||
type foo struct{ _ nocmp }
|
||||
|
||||
t.Run("struct copy", func(t *testing.T) {
|
||||
a := foo{}
|
||||
|
||||
@@ -24,7 +24,7 @@ package atomic
|
||||
|
||||
// String is an atomic type-safe wrapper for string values.
|
||||
type String struct {
|
||||
nocmp // disallow non-atomic comparison
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v Value
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
|
||||
// Uint32 is an atomic wrapper around uint32.
|
||||
type Uint32 struct {
|
||||
nocmp // disallow non-atomic comparison
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v uint32
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
|
||||
// Uint64 is an atomic wrapper around uint64.
|
||||
type Uint64 struct {
|
||||
nocmp // disallow non-atomic comparison
|
||||
_ nocmp // disallow non-atomic comparison
|
||||
|
||||
v uint64
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user