Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ linters:
# - iotamixing
- mirror
- misspell
# - modernize
- modernize
- nakedret
- nilerr
# - noctx
Expand Down Expand Up @@ -268,3 +268,6 @@ linters:
linters:
- gosec
- prealloc
- path: "^graft/"
linters:
- modernize
4 changes: 2 additions & 2 deletions api/admin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ func (c *Client) GetLoggerLevel(
return res.LoggerLevels, err
}

func (c *Client) GetConfig(ctx context.Context, options ...rpc.Option) (interface{}, error) {
var res interface{}
func (c *Client) GetConfig(ctx context.Context, options ...rpc.Option) (any, error) {
var res any
err := c.Requester.SendRequest(ctx, "admin.getConfig", struct{}{}, &res, options...)
return res, err
}
Expand Down
14 changes: 7 additions & 7 deletions api/admin/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ var (
)

type mockClient struct {
response interface{}
response any
err error
}

// NewMockClient returns a mock client for testing
func NewMockClient(response interface{}, err error) rpc.EndpointRequester {
func NewMockClient(response any, err error) rpc.EndpointRequester {
return &mockClient{
response: response,
err: err,
}
}

func (mc *mockClient) SendRequest(_ context.Context, _ string, _ interface{}, reply interface{}, _ ...rpc.Option) error {
func (mc *mockClient) SendRequest(_ context.Context, _ string, _ any, reply any, _ ...rpc.Option) error {
if mc.err != nil {
return mc.err
}
Expand All @@ -65,8 +65,8 @@ func (mc *mockClient) SendRequest(_ context.Context, _ string, _ interface{}, re
case *LoggerLevelReply:
response := mc.response.(*LoggerLevelReply)
*p = *response
case *interface{}:
response := mc.response.(*interface{})
case *any:
response := mc.response.(*any)
*p = *response
default:
panic("illegal type")
Expand Down Expand Up @@ -323,9 +323,9 @@ func TestGetConfig(t *testing.T) {
name string
serviceErr error
clientErr error
expectedResponse interface{}
expectedResponse any
}
var resp interface{} = "response"
var resp any = "response"
tests := []test{
{
name: "Happy path",
Expand Down
4 changes: 2 additions & 2 deletions api/admin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Config struct {
Log logging.Logger
ProfileDir string
LogFactory logging.Factory
NodeConfig interface{}
NodeConfig any
DB database.Database
ChainManager chains.Manager
HTTPServer server.PathAdderWithReadLock
Expand Down Expand Up @@ -311,7 +311,7 @@ func (a *Admin) GetLoggerLevel(_ *http.Request, args *GetLoggerLevelArgs, reply
}

// GetConfig returns the config that the node was started with.
func (a *Admin) GetConfig(_ *http.Request, _ *struct{}, reply *interface{}) error {
func (a *Admin) GetConfig(_ *http.Request, _ *struct{}, reply *any) error {
a.Log.Debug("API called",
zap.String("service", "admin"),
zap.String("method", "getConfig"),
Expand Down
6 changes: 3 additions & 3 deletions api/health/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ type Checker interface {
// error
//
// It is expected that the results are json marshallable.
HealthCheck(context.Context) (interface{}, error)
HealthCheck(context.Context) (any, error)
}

type CheckerFunc func(context.Context) (interface{}, error)
type CheckerFunc func(context.Context) (any, error)

func (f CheckerFunc) HealthCheck(ctx context.Context) (interface{}, error) {
func (f CheckerFunc) HealthCheck(ctx context.Context) (any, error) {
return f(ctx)
}
2 changes: 1 addition & 1 deletion api/health/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type mockClient struct {
onCall func()
}

func (mc *mockClient) SendRequest(_ context.Context, _ string, _ interface{}, replyIntf interface{}, _ ...rpc.Option) error {
func (mc *mockClient) SendRequest(_ context.Context, _ string, _ any, replyIntf any, _ ...rpc.Option) error {
reply := replyIntf.(*APIReply)
*reply = mc.reply
mc.onCall()
Expand Down
14 changes: 7 additions & 7 deletions api/health/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func awaitLiveness(t *testing.T, r Reporter, liveness bool) {
func TestDuplicatedRegistrations(t *testing.T) {
require := require.New(t)

check := CheckerFunc(func(context.Context) (interface{}, error) {
check := CheckerFunc(func(context.Context) (any, error) {
return "", nil
})

Expand All @@ -73,7 +73,7 @@ func TestDuplicatedRegistrations(t *testing.T) {
func TestDefaultFailing(t *testing.T) {
require := require.New(t)

check := CheckerFunc(func(context.Context) (interface{}, error) {
check := CheckerFunc(func(context.Context) (any, error) {
return "", nil
})

Expand Down Expand Up @@ -114,7 +114,7 @@ func TestDefaultFailing(t *testing.T) {
func TestPassingChecks(t *testing.T) {
require := require.New(t)

check := CheckerFunc(func(context.Context) (interface{}, error) {
check := CheckerFunc(func(context.Context) (any, error) {
return "", nil
})

Expand Down Expand Up @@ -175,7 +175,7 @@ func TestPassingThenFailingChecks(t *testing.T) {
require := require.New(t)

var shouldCheckErr utils.Atomic[bool]
check := CheckerFunc(func(context.Context) (interface{}, error) {
check := CheckerFunc(func(context.Context) (any, error) {
if shouldCheckErr.Get() {
return errUnhealthy.Error(), errUnhealthy
}
Expand Down Expand Up @@ -233,7 +233,7 @@ func TestDeadlockRegression(t *testing.T) {
require.NoError(err)

var lock sync.Mutex
check := CheckerFunc(func(context.Context) (interface{}, error) {
check := CheckerFunc(func(context.Context) (any, error) {
lock.Lock()
time.Sleep(time.Nanosecond)
lock.Unlock()
Expand All @@ -243,7 +243,7 @@ func TestDeadlockRegression(t *testing.T) {
h.Start(t.Context(), time.Nanosecond)
defer h.Stop()

for i := 0; i < 100; i++ {
for i := range 100 {
lock.Lock()
require.NoError(h.RegisterHealthCheck(fmt.Sprintf("check-%d", i), check))
lock.Unlock()
Expand All @@ -255,7 +255,7 @@ func TestDeadlockRegression(t *testing.T) {
func TestTags(t *testing.T) {
require := require.New(t)

check := CheckerFunc(func(context.Context) (interface{}, error) {
check := CheckerFunc(func(context.Context) (any, error) {
return "", nil
})

Expand Down
4 changes: 2 additions & 2 deletions api/health/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ func init() {

type Result struct {
// Details of the HealthCheck.
Details interface{} `json:"message,omitempty"`
Details any `json:"message,omitempty"`

// Error is the string representation of the error returned by the failing
// HealthCheck. The value is nil if the check passed.
Error *string `json:"error,omitempty"`

// Timestamp of the last HealthCheck.
Timestamp time.Time `json:"timestamp,omitempty"`
Timestamp time.Time `json:"timestamp"`

// Duration is the amount of time this HealthCheck last took to evaluate.
Duration time.Duration `json:"duration"`
Expand Down
4 changes: 2 additions & 2 deletions api/health/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
func TestServiceResponses(t *testing.T) {
require := require.New(t)

check := CheckerFunc(func(context.Context) (interface{}, error) {
check := CheckerFunc(func(context.Context) (any, error) {
return "", nil
})

Expand Down Expand Up @@ -106,7 +106,7 @@ func TestServiceResponses(t *testing.T) {
}

func TestServiceTagResponse(t *testing.T) {
check := CheckerFunc(func(context.Context) (interface{}, error) {
check := CheckerFunc(func(context.Context) (any, error) {
return "", nil
})

Expand Down
2 changes: 1 addition & 1 deletion api/info/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type mockClient struct {
onCall func()
}

func (mc *mockClient) SendRequest(_ context.Context, _ string, _ interface{}, replyIntf interface{}, _ ...rpc.Option) error {
func (mc *mockClient) SendRequest(_ context.Context, _ string, _ any, replyIntf any, _ ...rpc.Option) error {
reply := replyIntf.(*IsBootstrappedResponse)
*reply = mc.reply
mc.onCall()
Expand Down
2 changes: 1 addition & 1 deletion api/info/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var errTest = errors.New("non-nil error")

type testFactory struct{}

func (testFactory) New(logging.Logger) (interface{}, error) { return nil, nil }
func (testFactory) New(logging.Logger) (any, error) { return nil, nil }

type getVMsTest struct {
info *Info
Expand Down
6 changes: 3 additions & 3 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func (m *manager) createChain(chainParams ChainParameters) {
healthCheckErr := fmt.Errorf("failed to create chain on subnet %s: %w", chainParams.SubnetID, err)
err := m.Health.RegisterHealthCheck(
chainAlias,
health.CheckerFunc(func(context.Context) (interface{}, error) {
health.CheckerFunc(func(context.Context) (any, error) {
return nil, healthCheckErr
}),
chainParams.SubnetID.String(),
Expand Down Expand Up @@ -1472,7 +1472,7 @@ func (m *manager) IsBootstrapped(id ids.ID) bool {
}

func (m *manager) registerBootstrappedHealthChecks() error {
bootstrappedCheck := health.CheckerFunc(func(context.Context) (interface{}, error) {
bootstrappedCheck := health.CheckerFunc(func(context.Context) (any, error) {
if subnetIDs := m.Subnets.Bootstrapping(); len(subnetIDs) != 0 {
return subnetIDs, errNotBootstrapped
}
Expand All @@ -1491,7 +1491,7 @@ func (m *manager) registerBootstrappedHealthChecks() error {
return nil
}

partialSyncCheck := health.CheckerFunc(func(context.Context) (interface{}, error) {
partialSyncCheck := health.CheckerFunc(func(context.Context) (any, error) {
// Note: The health check is skipped during bootstrapping to allow a
// node to sync the network even if it was previously a validator.
if !m.IsBootstrapped(constants.PlatformChainID) {
Expand Down
6 changes: 3 additions & 3 deletions codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ var (

// Codec marshals and unmarshals
type Codec interface {
MarshalInto(interface{}, *wrappers.Packer) error
UnmarshalFrom(*wrappers.Packer, interface{}) error
MarshalInto(any, *wrappers.Packer) error
UnmarshalFrom(*wrappers.Packer, any) error

// Returns the size, in bytes, of [value] when it's marshaled
Size(value interface{}) (int, error)
Size(value any) (int, error)
}
68 changes: 34 additions & 34 deletions codec/codectest/codectest.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,39 +122,39 @@ type MyInnerStruct3 struct {
}

type myStruct struct {
InnerStruct MyInnerStruct `serialize:"true"`
InnerStruct2 *MyInnerStruct `serialize:"true"`
Member1 int64 `serialize:"true"`
Member2 uint16 `serialize:"true"`
MyArray2 [5]string `serialize:"true"`
MyArray3 [3]MyInnerStruct `serialize:"true"`
MyArray4 [2]*MyInnerStruct2 `serialize:"true"`
MySlice []byte `serialize:"true"`
MySlice2 []string `serialize:"true"`
MySlice3 []MyInnerStruct `serialize:"true"`
MySlice4 []*MyInnerStruct2 `serialize:"true"`
MyArray [4]byte `serialize:"true"`
MyInterface Foo `serialize:"true"`
MySlice5 []Foo `serialize:"true"`
InnerStruct3 MyInnerStruct3 `serialize:"true"`
MyPointer *Foo `serialize:"true"`
MyMap1 map[string]string `serialize:"true"`
MyMap2 map[int32][]MyInnerStruct3 `serialize:"true"`
MyMap3 map[MyInnerStruct2][]int32 `serialize:"true"`
MyMap4 map[int32]*int32 `serialize:"true"`
MyMap5 map[int32]int32 `serialize:"true"`
MyMap6 map[[5]int32]int32 `serialize:"true"`
MyMap7 map[interface{}]interface{} `serialize:"true"`
Uint8 uint8 `serialize:"true"`
Int8 int8 `serialize:"true"`
Uint16 uint16 `serialize:"true"`
Int16 int16 `serialize:"true"`
Uint32 uint32 `serialize:"true"`
Int32 int32 `serialize:"true"`
Uint64 uint64 `serialize:"true"`
Int64 int64 `serialize:"true"`
Bool bool `serialize:"true"`
String string `serialize:"true"`
InnerStruct MyInnerStruct `serialize:"true"`
InnerStruct2 *MyInnerStruct `serialize:"true"`
Member1 int64 `serialize:"true"`
Member2 uint16 `serialize:"true"`
MyArray2 [5]string `serialize:"true"`
MyArray3 [3]MyInnerStruct `serialize:"true"`
MyArray4 [2]*MyInnerStruct2 `serialize:"true"`
MySlice []byte `serialize:"true"`
MySlice2 []string `serialize:"true"`
MySlice3 []MyInnerStruct `serialize:"true"`
MySlice4 []*MyInnerStruct2 `serialize:"true"`
MyArray [4]byte `serialize:"true"`
MyInterface Foo `serialize:"true"`
MySlice5 []Foo `serialize:"true"`
InnerStruct3 MyInnerStruct3 `serialize:"true"`
MyPointer *Foo `serialize:"true"`
MyMap1 map[string]string `serialize:"true"`
MyMap2 map[int32][]MyInnerStruct3 `serialize:"true"`
MyMap3 map[MyInnerStruct2][]int32 `serialize:"true"`
MyMap4 map[int32]*int32 `serialize:"true"`
MyMap5 map[int32]int32 `serialize:"true"`
MyMap6 map[[5]int32]int32 `serialize:"true"`
MyMap7 map[any]any `serialize:"true"`
Uint8 uint8 `serialize:"true"`
Int8 int8 `serialize:"true"`
Uint16 uint16 `serialize:"true"`
Int16 int16 `serialize:"true"`
Uint32 uint32 `serialize:"true"`
Int32 int32 `serialize:"true"`
Uint64 uint64 `serialize:"true"`
Int64 int64 `serialize:"true"`
Bool bool `serialize:"true"`
String string `serialize:"true"`
}

// Test marshaling/unmarshaling a complicated struct
Expand All @@ -176,7 +176,7 @@ func TestStruct(t testing.TB, codec codecpkg.GeneralCodec) {
myMap6[[5]int32{0, 1, 2, 3, 4}] = 1
myMap6[[5]int32{1, 2, 3, 4, 5}] = 2

myMap7 := make(map[interface{}]interface{})
myMap7 := make(map[any]any)
myMap7["key"] = "value"
myMap7[int32(1)] = int32(2)

Expand Down
2 changes: 1 addition & 1 deletion codec/hierarchycodec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (c *hierarchyCodec) NextGroup() {

// RegisterType is used to register types that may be unmarshaled into an interface
// [val] is a value of the type being registered
func (c *hierarchyCodec) RegisterType(val interface{}) error {
func (c *hierarchyCodec) RegisterType(val any) error {
c.lock.Lock()
defer c.lock.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion codec/linearcodec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c *linearCodec) SkipRegistrations(num int) {

// RegisterType is used to register types that may be unmarshaled into an interface
// [val] is a value of the type being registered
func (c *linearCodec) RegisterType(val interface{}) error {
func (c *linearCodec) RegisterType(val any) error {
c.lock.Lock()
defer c.lock.Unlock()

Expand Down
Loading
Loading