Skip to content

Commit

Permalink
Merge pull request #757 from gobitfly/BEDS-310/migrate_go_1_23
Browse files Browse the repository at this point in the history
feat: update go to 1.23, update linter dependencies
  • Loading branch information
peterbitfly authored Aug 21, 2024
2 parents 8657478 + 8082874 commit 65f01b2
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 50 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/backend-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.23'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.56.1
version: v1.60.1
working-directory: backend
args: --timeout=5m

Expand Down
15 changes: 4 additions & 11 deletions backend/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,12 @@ linters:
- importas
- unparam
disable:
- exhaustivestruct
- golint
- ifshort
- interfacer
- maligned
- nosnakecase
- scopelint
- structcheck
- varcheck
- dupword
- gocognit
- dupl
# - mnd
- mnd
- copyloopvar
- intrange

# Disabled for now:
- asasalint
Expand All @@ -53,7 +46,7 @@ linters:
- gocyclo
- godot
- godox
- goerr113
- err113
- gofumpt
- gomnd
- gomoddirectives
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# this is meant to be built with the root of this repo as build-context
FROM golang:1.22.0 AS build-env
FROM golang:1.23.0 AS build-env
COPY backend/go.mod backend/go.sum /src/backend/
WORKDIR /src/backend
RUN go mod download
Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func main() {
flag.Parse()

if *versionFlag {
log.Infof(version.Version)
log.Infof(version.GoVersion)
log.Info(version.Version)
log.Info(version.GoVersion)
return
}

Expand Down
2 changes: 1 addition & 1 deletion backend/cmd/blobindexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func main() {
versionFlag := flag.Bool("version", false, "print version and exit")
flag.Parse()
if *versionFlag {
log.Infof(version.Version)
log.Info(version.Version)
return
}
utils.Config = &types.Config{}
Expand Down
6 changes: 3 additions & 3 deletions backend/cmd/eth1indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func main() {
flag.Parse()

if *versionFlag {
log.Infof(version.Version)
log.Infof(version.GoVersion)
log.Info(version.Version)
log.Info(version.GoVersion)
return
}

Expand Down Expand Up @@ -731,7 +731,7 @@ func ImportMainnetERC20TokenMetadataFromTokenDirectory(bt *db.Bigtable) {
if len(token.LogoURI) > 0 {
resp, err := client.Get(token.LogoURI)

if err == nil && resp.StatusCode == 200 {
if err == nil && resp.StatusCode == http.StatusOK {
body, err := io.ReadAll(resp.Body)

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/ethstore_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func main() {
flag.Parse()

if *versionFlag {
log.Infof(version.Version)
log.Infof(version.GoVersion)
log.Info(version.Version)
log.Info(version.GoVersion)
return
}

Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func main() {
flag.Parse()

if *versionFlag {
log.Infof(version.Version)
log.Infof(version.GoVersion)
log.Info(version.Version)
log.Info(version.GoVersion)
return
}

Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/misc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func main() {
flag.Parse()

if *versionFlag {
log.Infof(version.Version)
log.Info(version.Version)
return
}

Expand Down Expand Up @@ -763,7 +763,7 @@ func migrateAppPurchases(appStoreSecret string) error {
return errors.Wrap(err, "error verifying receipt")
}

if resp.LatestReceiptInfo == nil || len(resp.LatestReceiptInfo) == 0 {
if len(resp.LatestReceiptInfo) == 0 {
log.Infof("no receipt info for purchase id %v", receipt.ID)
if receipt.Active && receipt.ValidateRemotely { // sanity, if there is an active subscription without receipt info we cam't delete it.
return fmt.Errorf("no receipt info for active purchase id %v", receipt.ID)
Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/node_jobs_processor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func main() {
flag.Parse()

if *versionFlag {
log.Infof(version.Version)
log.Infof(version.GoVersion)
log.Info(version.Version)
log.Info(version.GoVersion)
return
}

Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/notification_collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func main() {
flag.Parse()

if *versionFlag {
log.Infof(version.Version)
log.Infof(version.GoVersion)
log.Info(version.Version)
log.Info(version.GoVersion)
return
}

Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/notification_sender/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func main() {
flag.Parse()

if *versionFlag {
log.Infof(version.Version)
log.Infof(version.GoVersion)
log.Info(version.Version)
log.Info(version.GoVersion)
return
}

Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/rewards_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func main() {
flag.Parse()

if *versionFlag {
log.Infof(version.Version)
log.Infof(version.GoVersion)
log.Info(version.Version)
log.Info(version.GoVersion)
return
}

Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/signatures/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func main() {
flag.Parse()

if *versionFlag {
log.Infof(version.Version)
log.Infof(version.GoVersion)
log.Info(version.Version)
log.Info(version.GoVersion)
return
}

Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/statistics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func main() {
flag.Parse()

if *versionFlag {
log.Infof(version.Version)
log.Infof(version.GoVersion)
log.Info(version.Version)
log.Info(version.GoVersion)
return
}

Expand Down
2 changes: 1 addition & 1 deletion backend/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/gobitfly/beaconchain

go 1.22
go 1.23

require (
cloud.google.com/go/bigtable v1.21.0
Expand Down
4 changes: 2 additions & 2 deletions backend/pkg/api/data_access/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ func NewDummyService() *DummyService {
rand.Shuffle(len(possibleChainIds), func(i, j int) {
possibleChainIds[i], possibleChainIds[j] = possibleChainIds[j], possibleChainIds[i]
})
return possibleChainIds[:rand.IntN(len(possibleChainIds))], nil
return possibleChainIds[:rand.IntN(len(possibleChainIds))], nil //nolint:gosec
})
return &DummyService{}
}

// generate random decimal.Decimal, should result in somewhere around 0.001 ETH (+/- a few decimal places) in Wei
func randomEthDecimal() decimal.Decimal {
decimal, _ := decimal.NewFromString(fmt.Sprintf("%d00000000000", rand.Int64N(10000000)))
decimal, _ := decimal.NewFromString(fmt.Sprintf("%d00000000000", rand.Int64N(10000000))) //nolint:gosec
return decimal
}

Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/blobindexer/blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (bi *BlobIndexer) IndexBlobsAtSlot(slot uint64) error {
if err != nil {
// Only put the object if it does not exist yet
var httpResponseErr *awshttp.ResponseError
if errors.As(err, &httpResponseErr) && (httpResponseErr.HTTPStatusCode() == 404 || httpResponseErr.HTTPStatusCode() == 403) {
if errors.As(err, &httpResponseErr) && (httpResponseErr.HTTPStatusCode() == http.StatusNotFound || httpResponseErr.HTTPStatusCode() == 403) {
tS3PutObj := time.Now()
_, putErr := bi.S3Client.PutObject(gCtx, &s3.PutObjectInput{
Bucket: &utils.Config.BlobIndexer.S3.Bucket,
Expand Down
8 changes: 4 additions & 4 deletions backend/pkg/commons/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func InfoWithFields(additionalInfos Fields, msg string) {
logFields = logFields.WithField(name, info)
}

logFields.Infof(msg)
logFields.Info(msg)
}

func Warn(args ...interface{}) {
Expand All @@ -57,7 +57,7 @@ func WarnWithFields(additionalInfos Fields, msg string) {
logFields = logFields.WithField(name, info)
}

logFields.Warnf(msg)
logFields.Warn(msg)
}

func Tracef(format string, args ...interface{}) {
Expand All @@ -70,7 +70,7 @@ func TraceWithFields(additionalInfos Fields, msg string) {
logFields = logFields.WithField(name, info)
}

logFields.Tracef(msg)
logFields.Trace(msg)
}

func DebugWithFields(additionalInfos Fields, msg string) {
Expand All @@ -79,7 +79,7 @@ func DebugWithFields(additionalInfos Fields, msg string) {
logFields = logFields.WithField(name, info)
}

logFields.Debugf(msg)
logFields.Debug(msg)
}

func Debugf(format string, args ...interface{}) {
Expand Down
7 changes: 4 additions & 3 deletions backend/pkg/exporter/modules/dashboard_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"database/sql"
"fmt"
"math"
"net/http"
"regexp"
"sort"
"strconv"
Expand Down Expand Up @@ -1214,7 +1215,7 @@ func (d *dashboardData) getData(epoch, slotsPerEpoch uint64, skipSerialCalls boo
_, err := cl.GetBlockHeader(slot)
if err != nil {
httpErr := network.SpecificError(err)
if httpErr != nil && httpErr.StatusCode == 404 {
if httpErr != nil && httpErr.StatusCode == http.StatusNotFound {
result.missedslots[slot] = true
continue // missed
}
Expand All @@ -1236,7 +1237,7 @@ func (d *dashboardData) getData(epoch, slotsPerEpoch uint64, skipSerialCalls boo
block, err := cl.GetSlot(slot)
if err != nil {
httpErr := network.SpecificError(err)
if httpErr != nil && httpErr.StatusCode == 404 {
if httpErr != nil && httpErr.StatusCode == http.StatusNotFound {
mutex.Lock()
result.missedslots[slot] = true
mutex.Unlock()
Expand Down Expand Up @@ -1835,7 +1836,7 @@ func refreshMaterializedSlashedByCounts() error {
// blockReward, err := d.CL.GetPropoalRewards(slot)
// if err != nil {
// httpErr := network.SpecificError(err)
// if httpErr != nil && httpErr.StatusCode == 404 {
// if httpErr != nil && httpErr.StatusCode == http.StatusNotFound {
// return nil
// }

Expand Down
3 changes: 2 additions & 1 deletion backend/pkg/exporter/modules/rocketpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/gobitfly/beaconchain/pkg/commons/db"
"github.com/gobitfly/beaconchain/pkg/commons/log"
"github.com/gobitfly/beaconchain/pkg/commons/utils"
"github.com/pkg/errors"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
Expand Down Expand Up @@ -1847,7 +1848,7 @@ func DownloadRewardsFile(fileName string, interval uint64, cid string, isDaemon
}
}

return nil, fmt.Errorf(errBuilder.String())
return nil, errors.New(errBuilder.String())
}

// Decompresses a rewards file
Expand Down

0 comments on commit 65f01b2

Please sign in to comment.