chore_: bump go to 1.20 (#5027)

This commit attempts to upgrade go version to 1.20.12
This commit also removes the following items from lint checks :
* `goconst`
* `structcheck`
* `deadcode`
* `golint`
* `varcheck`

Mobile PR for QA purposes -> https://github.com/status-im/status-mobile/pull/19564
This commit is contained in:
Siddarth Kumar 2024-04-18 18:48:02 +02:00 committed by GitHub
parent 78db9054fc
commit d6c4682479
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 57 additions and 24 deletions

View File

@ -42,22 +42,17 @@ linters-settings:
linters: linters:
disable-all: true disable-all: true
enable: enable:
- deadcode
- errcheck - errcheck
- gosec - gosec
- goconst
- goimports - goimports
- golint
- govet - govet
- ineffassign - ineffassign
- megacheck - megacheck
- misspell - misspell
- structcheck
# You can't disable typecheck, see: # You can't disable typecheck, see:
# https://github.com/golangci/golangci-lint/blob/master/docs/src/docs/welcome/faq.mdx#why-do-you-have-typecheck-errors # https://github.com/golangci/golangci-lint/blob/master/docs/src/docs/welcome/faq.mdx#why-do-you-have-typecheck-errors
- typecheck - typecheck
- unconvert - unconvert
- varcheck
fast: false fast: false
issues: issues:

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/status-im/status-go module github.com/status-im/status-go
go 1.19 go 1.20
replace github.com/ethereum/go-ethereum v1.10.26 => github.com/status-im/go-ethereum v1.10.25-status.13 replace github.com/ethereum/go-ethereum v1.10.26 => github.com/status-im/go-ethereum v1.10.25-status.13

View File

@ -107,7 +107,9 @@ func (s *MailserverSuite) TestInit() {
}, },
} }
for _, tc := range testCases { for _, testCase := range testCases {
// to satisfy gosec: C601 checks
tc := testCase
s.T().Run(tc.info, func(*testing.T) { s.T().Run(tc.info, func(*testing.T) {
mailServer := &WakuMailServer{} mailServer := &WakuMailServer{}
shh := waku.New(&waku.DefaultConfig, nil) shh := waku.New(&waku.DefaultConfig, nil)
@ -299,7 +301,9 @@ func (s *MailserverSuite) TestMailServer() {
info: "Processing a request where difference between from and to is > 24 should fail", info: "Processing a request where difference between from and to is > 24 should fail",
}, },
} }
for _, tc := range testCases { for _, testCase := range testCases {
// to satisfy gosec: C601 checks
tc := testCase
s.T().Run(tc.info, func(*testing.T) { s.T().Run(tc.info, func(*testing.T) {
request := s.createRequest(tc.params) request := s.createRequest(tc.params)
src := crypto.FromECDSAPub(&tc.params.key.PublicKey) src := crypto.FromECDSAPub(&tc.params.key.PublicKey)

View File

@ -263,7 +263,8 @@ func (db *Database) deleteKeycardAccounts(tx *sql.Tx, kcUID string, accountAddre
} }
inVector := strings.Repeat(",?", len(accountAddresses)-1) inVector := strings.Repeat(",?", len(accountAddresses)-1)
query := ` //nolint: gosec
query := `
DELETE DELETE
FROM FROM
keycards_accounts keycards_accounts

View File

@ -22,12 +22,12 @@ in rec {
]; ];
}; };
go = prev.go_1_19; go = prev.go_1_20;
buildGoModule = prev.buildGo119Module; buildGoModule = prev.buildGo120Module;
buildGoPackage = prev.buildGo119Package; buildGoPackage = prev.buildGo120Package;
golangci-lint = prev.golangci-lint.override { golangci-lint = prev.golangci-lint.override {
buildGoModule = args: prev.buildGo119Module ( args // rec { buildGoModule = args: prev.buildGo120Module ( args // rec {
version = "1.52.2"; version = "1.52.2";
src = prev.fetchFromGitHub { src = prev.fetchFromGitHub {
owner = "golangci"; owner = "golangci";

View File

@ -853,7 +853,7 @@ func (db sqlitePersistence) MarkActivityCenterNotificationsDeleted(ids []types.H
return nil, err return nil, err
} }
update := "UPDATE activity_center_notifications SET deleted = 1, updated_at = ? WHERE id IN (" + inVector + ") AND NOT deleted" update := "UPDATE activity_center_notifications SET deleted = 1, updated_at = ? WHERE id IN (" + inVector + ") AND NOT deleted" //nolint: gosec
_, err = tx.Exec(update, args...) _, err = tx.Exec(update, args...)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -960,7 +960,7 @@ func (p *Persistence) GetLatestWakuMessageTimestamp(topics []types.TopicType) (u
func (p *Persistence) GetWakuMessagesByFilterTopic(topics []types.TopicType, from uint64, to uint64) ([]types.Message, error) { func (p *Persistence) GetWakuMessagesByFilterTopic(topics []types.TopicType, from uint64, to uint64) ([]types.Message, error) {
query := "SELECT sig, timestamp, topic, payload, padding, hash, third_party_id FROM waku_messages WHERE timestamp >= " + fmt.Sprint(from) + " AND timestamp < " + fmt.Sprint(to) + " AND (" query := "SELECT sig, timestamp, topic, payload, padding, hash, third_party_id FROM waku_messages WHERE timestamp >= " + fmt.Sprint(from) + " AND timestamp < " + fmt.Sprint(to) + " AND (" //nolint: gosec
for i, topic := range topics { for i, topic := range topics {
query += `topic = "` + topic.String() + `"` query += `topic = "` + topic.String() + `"`

View File

@ -3016,7 +3016,7 @@ func (db sqlitePersistence) findStatusMessageIDForBridgeMessageID(tx *sql.Tx, me
} }
func (db sqlitePersistence) updateStatusMessagesWithResponse(tx *sql.Tx, statusMessagesToUpdate []string, responseValue string) error { func (db sqlitePersistence) updateStatusMessagesWithResponse(tx *sql.Tx, statusMessagesToUpdate []string, responseValue string) error {
sql := "UPDATE user_messages SET response_to = ? WHERE id IN (?" + strings.Repeat(",?", len(statusMessagesToUpdate)-1) + ")" sql := "UPDATE user_messages SET response_to = ? WHERE id IN (?" + strings.Repeat(",?", len(statusMessagesToUpdate)-1) + ")" //nolint: gosec
stmt, err := tx.Prepare(sql) stmt, err := tx.Prepare(sql)
if err != nil { if err != nil {
return err return err

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"math" "math"
"math/big" "math/big"
"net"
"runtime" "runtime"
"sort" "sort"
"strings" "strings"
@ -27,6 +28,8 @@ const defaultBackoff = 10 * time.Second
const graylistBackoff = 3 * time.Minute const graylistBackoff = 3 * time.Minute
const isAndroidEmulator = runtime.GOOS == "android" && runtime.GOARCH == "amd64" const isAndroidEmulator = runtime.GOOS == "android" && runtime.GOARCH == "amd64"
const findNearestMailServer = !isAndroidEmulator const findNearestMailServer = !isAndroidEmulator
const overrideDNS = runtime.GOOS == "android"
const bootstrapDNS = "8.8.8.8:53"
func (m *Messenger) mailserversByFleet(fleet string) []mailservers.Mailserver { func (m *Messenger) mailserversByFleet(fleet string) []mailservers.Mailserver {
return mailservers.DefaultMailserversByFleet(fleet) return mailservers.DefaultMailserversByFleet(fleet)
@ -219,6 +222,22 @@ type SortedMailserver struct {
} }
func (m *Messenger) findNewMailserver() error { func (m *Messenger) findNewMailserver() error {
// we have to override DNS manually because of https://github.com/status-im/status-mobile/issues/19581
if overrideDNS {
var dialer net.Dialer
net.DefaultResolver = &net.Resolver{
PreferGo: false,
Dial: func(context context.Context, _, _ string) (net.Conn, error) {
conn, err := dialer.DialContext(context, "udp", bootstrapDNS)
if err != nil {
return nil, err
}
return conn, nil
},
}
}
pinnedMailserver, err := m.getPinnedMailserver() pinnedMailserver, err := m.getPinnedMailserver()
if err != nil { if err != nil {
m.logger.Error("Could not obtain the pinned mailserver", zap.Error(err)) m.logger.Error("Could not obtain the pinned mailserver", zap.Error(err))

View File

@ -150,7 +150,9 @@ func (f *FiltersManager) InitCommunityFilters(communityFiltersToInitialize []Com
f.mutex.Lock() f.mutex.Lock()
defer f.mutex.Unlock() defer f.mutex.Unlock()
for _, cf := range communityFiltersToInitialize { for _, communityFilter := range communityFiltersToInitialize {
// to satisfy gosec: C601 checks
cf := communityFilter
if cf.PrivKey == nil { if cf.PrivKey == nil {
continue continue
} }

View File

@ -499,7 +499,9 @@ func (s *Service) notifyCommunityCollectiblesReceived(ownedCollectibles OwnedCol
} }
groups := make(map[CollectibleGroup]Collectible) groups := make(map[CollectibleGroup]Collectible)
for _, collectible := range communityCollectibles { for _, localCollectible := range communityCollectibles {
// to satisfy gosec: C601 checks
collectible := localCollectible
txHash := "" txHash := ""
for key, value := range hashMap { for key, value := range hashMap {
if key.Same(&collectible.ID) { if key.Same(&collectible.ID) {

View File

@ -159,7 +159,9 @@ func fullCollectiblesDataToDetails(data []thirdparty.FullCollectibleData) []Coll
func fullCollectiblesDataToCommunityHeader(data []thirdparty.FullCollectibleData) []Collectible { func fullCollectiblesDataToCommunityHeader(data []thirdparty.FullCollectibleData) []Collectible {
res := make([]Collectible, 0, len(data)) res := make([]Collectible, 0, len(data))
for _, c := range data { for _, localCollectibleData := range data {
// to satisfy gosec: C601 checks
c := localCollectibleData
collectibleID := c.CollectibleData.ID collectibleID := c.CollectibleData.ID
communityID := c.CollectibleData.CommunityID communityID := c.CollectibleData.CommunityID

View File

@ -115,7 +115,7 @@ func (b *BlockRangeSequentialDAO) getBlockRanges(chainID uint64, addresses []com
} }
} }
query := "SELECT address, blk_start, blk_first, blk_last, token_blk_start, token_blk_first, token_blk_last, balance_check_hash FROM blocks_ranges_sequential WHERE address IN (" + query := "SELECT address, blk_start, blk_first, blk_last, token_blk_start, token_blk_first, token_blk_last, balance_check_hash FROM blocks_ranges_sequential WHERE address IN (" + //nolint: gosec
addressesPlaceholder + ") AND network_id = ?" addressesPlaceholder + ") AND network_id = ?"
params := []interface{}{} params := []interface{}{}

View File

@ -326,7 +326,9 @@ func insertBlocksWithTransactions(chainID uint64, creator statementCreator, head
func updateOrInsertTransfers(chainID uint64, creator statementCreator, transfers []Transfer) error { func updateOrInsertTransfers(chainID uint64, creator statementCreator, transfers []Transfer) error {
txsDBFields := make([]transferDBFields, 0, len(transfers)) txsDBFields := make([]transferDBFields, 0, len(transfers))
for _, t := range transfers { for _, localTransfer := range transfers {
// to satisfy gosec: C601 checks
t := localTransfer
var receiptType *uint8 var receiptType *uint8
var txHash, blockHash *common.Hash var txHash, blockHash *common.Hash
var receiptStatus, cumulativeGasUsed, gasUsed *uint64 var receiptStatus, cumulativeGasUsed, gasUsed *uint64

View File

@ -143,7 +143,9 @@ func MockTestTransactions(t *testing.T, chainClient *MockChainClient, testTxs []
return false return false
} }
for i := range b { for i := range b {
for _, sum := range chainSummaries { for _, localSummary := range chainSummaries {
// to satisfy gosec: C601 checks
sum := localSummary
tx := &sum.tx tx := &sum.tx
if sum.answered { if sum.answered {
continue continue
@ -165,7 +167,9 @@ func MockTestTransactions(t *testing.T, chainClient *MockChainClient, testTxs []
require.True(t, ok) require.True(t, ok)
require.NotNil(t, receiptWrapper) require.NotNil(t, receiptWrapper)
// Simulate parsing of eth_getTransactionReceipt response // Simulate parsing of eth_getTransactionReceipt response
for _, sum := range chainSummaries { for _, localSum := range chainSummaries {
// to satisfy gosec: C601 checks
sum := localSum
tx := &sum.tx tx := &sum.tx
if tx.Hash == elems[i].Args[0].(eth.Hash) { if tx.Hash == elems[i].Args[0].(eth.Hash) {
if !sum.summary.DontConfirm { if !sum.summary.DontConfirm {

View File

@ -266,7 +266,9 @@ func (s *TransactorSuite) TestSendTransactionWithSignature() {
}, },
} }
for _, scenario := range scenarios { for _, localScenario := range scenarios {
// to satisfy gosec: C601 checks
scenario := localScenario
desc := fmt.Sprintf("nonceFromNetwork: %d, tx nonce: %d, expect error: %v", scenario.nonceFromNetwork, scenario.txNonce, scenario.expectError) desc := fmt.Sprintf("nonceFromNetwork: %d, tx nonce: %d, expect error: %v", scenario.nonceFromNetwork, scenario.txNonce, scenario.expectError)
s.T().Run(desc, func(t *testing.T) { s.T().Run(desc, func(t *testing.T) {
nonce := scenario.txNonce nonce := scenario.txNonce