diff --git a/certificate/certificatepb/gen.go b/certificate/certificatepb/gen.go index 529e04bf1..b5e966047 100644 --- a/certificate/certificatepb/gen.go +++ b/certificate/certificatepb/gen.go @@ -1,6 +1,7 @@ // Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. +//go:build ignore // +build ignore package main diff --git a/cmd/storagenode-updater/loop_windows.go b/cmd/storagenode-updater/loop_windows.go index 2352cf819..fb519fadb 100644 --- a/cmd/storagenode-updater/loop_windows.go +++ b/cmd/storagenode-updater/loop_windows.go @@ -1,6 +1,7 @@ // Copyright (C) 2020 Storj Labs, Inc. // See LICENSE for copying information. +//go:build windows && !unittest // +build windows,!unittest package main diff --git a/cmd/storagenode-updater/main_windows.go b/cmd/storagenode-updater/main_windows.go index cb762df91..cd25a07bb 100644 --- a/cmd/storagenode-updater/main_windows.go +++ b/cmd/storagenode-updater/main_windows.go @@ -7,6 +7,7 @@ // // sc.exe create storagenode-updater binpath= "C:\Users\MyUser\storagenode-updater.exe run ..." +//go:build windows // +build windows package main diff --git a/cmd/storagenode-updater/restart_linux.go b/cmd/storagenode-updater/restart_linux.go index 3b5c45aed..c043dfd26 100644 --- a/cmd/storagenode-updater/restart_linux.go +++ b/cmd/storagenode-updater/restart_linux.go @@ -1,6 +1,7 @@ // Copyright (C) 2020 Storj Labs, Inc. // See LICENSE for copying information. +//go:build linux && service // +build linux,service package main diff --git a/cmd/storagenode-updater/restart_windows.go b/cmd/storagenode-updater/restart_windows.go index dc1a958a7..570cb514f 100644 --- a/cmd/storagenode-updater/restart_windows.go +++ b/cmd/storagenode-updater/restart_windows.go @@ -1,6 +1,7 @@ // Copyright (C) 2020 Storj Labs, Inc. // See LICENSE for copying information. +//go:build windows && service // +build windows,service package main diff --git a/cmd/storagenode/service_windows.go b/cmd/storagenode/service_windows.go index 54a491054..7d7c9cc08 100644 --- a/cmd/storagenode/service_windows.go +++ b/cmd/storagenode/service_windows.go @@ -61,7 +61,7 @@ func (m *service) Execute(args []string, r <-chan svc.ChangeRequest, changes cha process.Exec(rootCmd) return nil }) - defer group.Wait() + defer func() { _ = group.Wait() }() changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted} diff --git a/private/crashreportpb/gen.go b/private/crashreportpb/gen.go index bb6c2eb8e..40729938c 100644 --- a/private/crashreportpb/gen.go +++ b/private/crashreportpb/gen.go @@ -1,6 +1,7 @@ // Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. +//go:build ignore // +build ignore package main diff --git a/private/cui/example.go b/private/cui/example.go index c64074890..7c8616830 100644 --- a/private/cui/example.go +++ b/private/cui/example.go @@ -1,6 +1,7 @@ // Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. +//go:build ignore // +build ignore package main diff --git a/private/multinodepb/gen.go b/private/multinodepb/gen.go index ee10f80c7..d6460ee8a 100644 --- a/private/multinodepb/gen.go +++ b/private/multinodepb/gen.go @@ -1,6 +1,7 @@ // Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. +//go:build ignore // +build ignore package main diff --git a/satellite/admin/oauthclients_testplanet_test.go b/satellite/admin/oauthclients_testplanet_test.go index e9432d810..118227577 100644 --- a/satellite/admin/oauthclients_testplanet_test.go +++ b/satellite/admin/oauthclients_testplanet_test.go @@ -75,7 +75,9 @@ func TestAdminOAuthAPI(t *testing.T) { body := "" if testCase.request != nil { - if data, _ := json.Marshal(testCase.request); len(data) > 0 { + data, err := json.Marshal(testCase.request) + require.NoError(t, err) + if len(data) > 0 { body = string(data) } } diff --git a/satellite/console/wasm/main.go b/satellite/console/wasm/main.go index 553215da2..296e6e9dc 100644 --- a/satellite/console/wasm/main.go +++ b/satellite/console/wasm/main.go @@ -1,4 +1,6 @@ +//go:build js && wasm // +build js,wasm + // Copyright (C) 2020 Storj Labs, Inc. // See LICENSE for copying information. diff --git a/satellite/internalpb/gen.go b/satellite/internalpb/gen.go index bf0652356..cd7179a88 100644 --- a/satellite/internalpb/gen.go +++ b/satellite/internalpb/gen.go @@ -1,6 +1,7 @@ // Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. +//go:build ignore // +build ignore package main diff --git a/satellite/oidc/oauth_stores.go b/satellite/oidc/oauth_stores.go index c7f7d9663..d3c7c551c 100644 --- a/satellite/oidc/oauth_stores.go +++ b/satellite/oidc/oauth_stores.go @@ -12,12 +12,15 @@ import ( "storj.io/common/uuid" ) -// clientStore provides a simple adapter for the oauth implementation. -type clientStore struct { +// ClientStore provides a simple adapter for the oauth implementation. +type ClientStore struct { clients OAuthClients } -func (c *clientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error) { +var _ oauth2.ClientStore = (*ClientStore)(nil) + +// GetByID returns client information by id. +func (c *ClientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error) { uid, err := uuid.FromString(id) if err != nil { return nil, err @@ -26,13 +29,16 @@ func (c *clientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo return c.clients.Get(ctx, uid) } -// tokenStore provides a simple adapter for the oauth implementation. -type tokenStore struct { +// TokenStore provides a simple adapter for the oauth implementation. +type TokenStore struct { codes OAuthCodes tokens OAuthTokens } -func (t *tokenStore) Create(ctx context.Context, info oauth2.TokenInfo) (err error) { +var _ oauth2.TokenStore = (*TokenStore)(nil) + +// Create creates a new token with the given info. +func (t *TokenStore) Create(ctx context.Context, info oauth2.TokenInfo) (err error) { var code OAuthCode var access, refresh OAuthToken @@ -108,19 +114,23 @@ func (t *tokenStore) Create(ctx context.Context, info oauth2.TokenInfo) (err err return nil } -func (t *tokenStore) RemoveByCode(ctx context.Context, code string) error { +// RemoveByCode deletes token by authorization code. +func (t *TokenStore) RemoveByCode(ctx context.Context, code string) error { return t.codes.Claim(ctx, code) } -func (t *tokenStore) RemoveByAccess(ctx context.Context, access string) error { +// RemoveByAccess deletes token by access token. +func (t *TokenStore) RemoveByAccess(ctx context.Context, access string) error { return nil // unsupported by current configuration } -func (t *tokenStore) RemoveByRefresh(ctx context.Context, refresh string) error { +// RemoveByRefresh deletes token by refresh token. +func (t *TokenStore) RemoveByRefresh(ctx context.Context, refresh string) error { return nil // unsupported by current configuration } -func (t *tokenStore) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error) { +// GetByCode uses authorization code to find token information. +func (t *TokenStore) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error) { oauthCode, err := t.codes.Get(ctx, code) if err != nil { return nil, err @@ -129,7 +139,8 @@ func (t *tokenStore) GetByCode(ctx context.Context, code string) (oauth2.TokenIn return &record{code: oauthCode}, nil } -func (t *tokenStore) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error) { +// GetByAccess uses access token to find token information. +func (t *TokenStore) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error) { oauthToken, err := t.tokens.Get(ctx, KindAccessToken, access) if err != nil { return nil, err @@ -138,7 +149,8 @@ func (t *tokenStore) GetByAccess(ctx context.Context, access string) (oauth2.Tok return &record{access: oauthToken}, nil } -func (t *tokenStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error) { +// GetByRefresh uses refresh token to find token information. +func (t *TokenStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error) { oauthToken, err := t.tokens.Get(ctx, KindRefreshToken, refresh) if err != nil { return nil, err diff --git a/satellite/oidc/service.go b/satellite/oidc/service.go index ecccb4949..c6802a18d 100644 --- a/satellite/oidc/service.go +++ b/satellite/oidc/service.go @@ -18,15 +18,15 @@ type Service struct { } // ClientStore returns a store used to lookup oauth clients from the consent flow. -func (s *Service) ClientStore() *clientStore { - return &clientStore{ +func (s *Service) ClientStore() *ClientStore { + return &ClientStore{ clients: s.store.OAuthClients(), } } // TokenStore returns a store used to manage access tokens during the consent flow. -func (s *Service) TokenStore() *tokenStore { - return &tokenStore{ +func (s *Service) TokenStore() *TokenStore { + return &TokenStore{ codes: s.store.OAuthCodes(), tokens: s.store.OAuthTokens(), } diff --git a/satellite/satellitedb/migrate_gen.go b/satellite/satellitedb/migrate_gen.go index 6fd403cf4..eeb9fcb13 100644 --- a/satellite/satellitedb/migrate_gen.go +++ b/satellite/satellitedb/migrate_gen.go @@ -1,7 +1,8 @@ // Copyright (C) 2021 Storj Labs, Inc. // See LICENSE for copying information. -//+build ignore +//go:build ignore +// +build ignore package main diff --git a/satellite/satellitedb/migrate_test.go b/satellite/satellitedb/migrate_test.go index c471cfa10..68dd79df1 100644 --- a/satellite/satellitedb/migrate_test.go +++ b/satellite/satellitedb/migrate_test.go @@ -84,7 +84,7 @@ func loadSnapshots(ctx context.Context, connstr, dbxscript string) (*dbschema.Sn if err != nil { var pgErr *pgconn.PgError if errors.As(err, &pgErr) { - return fmt.Errorf("Version %d error: %v\nDetail: %s\nHint: %s", version, pgErr, pgErr.Detail, pgErr.Hint) + return fmt.Errorf("Version %d error: %w\nDetail: %s\nHint: %s", version, pgErr, pgErr.Detail, pgErr.Hint) } return fmt.Errorf("Version %d error: %w", version, err) } diff --git a/scripts/pg-to-crdb.go b/scripts/pg-to-crdb.go index 9765ec5c9..5f0e6587f 100644 --- a/scripts/pg-to-crdb.go +++ b/scripts/pg-to-crdb.go @@ -1,6 +1,7 @@ // Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. +//go:build ignore // +build ignore package main diff --git a/scripts/test-network-stalls.go b/scripts/test-network-stalls.go index 0349ee0a5..0e6cb69a6 100644 --- a/scripts/test-network-stalls.go +++ b/scripts/test-network-stalls.go @@ -1,6 +1,7 @@ // Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. +//go:build ignore // +build ignore // Tests whether the uplink tool correctly times out when one of the storage nodes it's talking to diff --git a/scripts/update-access.go b/scripts/update-access.go index 28bc7b7fa..8b80addab 100644 --- a/scripts/update-access.go +++ b/scripts/update-access.go @@ -1,6 +1,7 @@ // Copyright (C) 2020 Storj Labs, Inc. // See LICENSE for copying information. +//go:build ignore // +build ignore package main diff --git a/storage/filestore/dir_windows.go b/storage/filestore/dir_windows.go index fbfea31b2..759c42206 100644 --- a/storage/filestore/dir_windows.go +++ b/storage/filestore/dir_windows.go @@ -1,6 +1,7 @@ // Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. +//go:build windows // +build windows package filestore diff --git a/storagenode/internalpb/gen.go b/storagenode/internalpb/gen.go index 65cc7c354..32b5167c6 100644 --- a/storagenode/internalpb/gen.go +++ b/storagenode/internalpb/gen.go @@ -1,6 +1,7 @@ // Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. +//go:build ignore // +build ignore package main diff --git a/storagenode/storagenodedb/schemagen.go b/storagenode/storagenodedb/schemagen.go index 104b7db9d..1c79bcbfc 100644 --- a/storagenode/storagenodedb/schemagen.go +++ b/storagenode/storagenodedb/schemagen.go @@ -1,6 +1,7 @@ // Copyright (C) 2020 Storj Labs, Inc. // See LICENSE for copying information. +//go:build ignore // +build ignore package main