Skip to content

Commit

Permalink
update to go 1.24
Browse files Browse the repository at this point in the history
Signed-off-by: p4u <pau@dabax.net>
  • Loading branch information
p4u committed Feb 28, 2025
1 parent db31f07 commit b090324
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 88 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Set up Go environment
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
- name: Tidy go module
run: |
go mod tidy
Expand All @@ -54,7 +54,7 @@ jobs:
fi
- name: Run staticcheck
run: |
go install honnef.co/go/tools/cmd/staticcheck@2024.1.1
go install honnef.co/go/tools/cmd/staticcheck@2025.1
staticcheck -debug.version
staticcheck ./... 2> staticcheck-stderr
- name: Check staticcheck stderr (this step isn't needed because we are using actions/setup-go@v5 on GitHub hosted runner)
Expand All @@ -81,7 +81,7 @@ jobs:
- uses: benjlevesque/short-sha@v3.0 # sets env.SHA to the first 7 chars of github.sha
- uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
- run: mkdir -p "$PWD/gocoverage-unit/"
- name: Run Go test -race
id: go-test-race
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
- uses: actions/download-artifact@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
cache: false
- name: Convert gocoverage format
run: |
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:
name: gocoverage-all-textfmt@${{ env.SHA }}
- uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
cache: false
- name: Send coverage to coveralls.io (unit)
if: ${{ always() }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
path: developer-portal
- uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version: '1.24'
cache: false
- name: Install swag
run: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:experimental

FROM golang:1.23 AS builder
FROM golang:1.24 AS builder

ARG BUILDARGS

Expand Down
2 changes: 1 addition & 1 deletion api/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func (a *API) walletElectionHandler(msg *apirest.APIdata, ctx *httprouter.HTTPCo
Metadata: &metadataURI,
}

log.Debugf(log.FormatProto(process))
log.Debugf("%s", log.FormatProto(process))

stx := models.SignedTx{}
if stx.Tx, err = proto.Marshal(&models.Tx{
Expand Down
86 changes: 43 additions & 43 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func main() {
account = fmt.Sprintf("%s [%s]", a.Memo, a.Address.String())
}
return fmt.Sprintf("%s | %s",
color.New(color.FgHiGreen, color.Bold, color.Underline).Sprintf(cli.chainID),
color.New(color.FgHiBlue).Sprintf(account),
color.New(color.FgHiGreen, color.Bold, color.Underline).Sprint(cli.chainID),
color.New(color.FgHiBlue).Sprint(account),
)
}

Expand Down Expand Up @@ -93,7 +93,7 @@ func main() {

option, _, err := prompt.Run()
if err != nil {
errorp.Printf("prompt failed: %v\n", err)
errorp.Print("prompt failed: ", err, "\n")
os.Exit(1)
}
switch option {
Expand Down Expand Up @@ -196,7 +196,7 @@ func accountHandler(c *VocdoniCLI) error {
return err
}
default:
infoPrint.Printf("using account %d\n", opt)
infoPrint.Print("using account ", opt, "\n")
if err := c.useAccount(opt); err != nil {
return err
}
Expand All @@ -219,7 +219,7 @@ func accountSet(c *VocdoniCLI) error {
if err != nil {
return err
}
infoPrint.Printf("set account %s\n", key)
infoPrint.Print("set account ", key, "\n")
return c.setAPIaccount(key, memo)
}

Expand All @@ -232,7 +232,7 @@ func accountGen(c *VocdoniCLI) error {
return err
}
key := fmt.Sprintf("%x", util.RandomBytes(32))
infoPrint.Printf("set account %s\n", memo)
infoPrint.Print("set account ", memo, "\n")
return c.setAPIaccount(key, memo)
}

Expand All @@ -242,21 +242,21 @@ func accountInfo(c *VocdoniCLI) error {
return err
}
localAcc := c.getCurrentAccount()
infoPrint.Printf("details for account %s\n", localAcc.Memo)
fmt.Printf("%s: %s\n", keysPrint.Sprintf(" ➥ address"), valuesPrint.Sprintf(acc.Address.String()))
fmt.Printf("%s: %s\n", keysPrint.Sprintf(" ➥ public key"), valuesPrint.Sprintf(localAcc.PublicKey.String()))
fmt.Printf("%s: %s\n", keysPrint.Sprintf(" ➥ balance"), valuesPrint.Sprintf("%d", acc.Balance))
fmt.Printf("%s: %s\n", keysPrint.Sprintf(" ➥ nonce"), valuesPrint.Sprintf("%d", acc.Nonce))
fmt.Printf("%s: %s\n", keysPrint.Sprintf(" ➥ electionIndex"), valuesPrint.Sprintf("%d", acc.ElectionIndex))
infoPrint.Print("details for account ", localAcc.Memo, "\n")
fmt.Printf("%s: %s\n", keysPrint.Sprint(" ➥ address"), valuesPrint.Sprint(acc.Address.String()))
fmt.Printf("%s: %s\n", keysPrint.Sprint(" ➥ public key"), valuesPrint.Sprint(localAcc.PublicKey.String()))
fmt.Printf("%s: %s\n", keysPrint.Sprint(" ➥ balance"), valuesPrint.Sprint(acc.Balance))
fmt.Printf("%s: %s\n", keysPrint.Sprint(" ➥ nonce"), valuesPrint.Sprint(acc.Nonce))
fmt.Printf("%s: %s\n", keysPrint.Sprint(" ➥ electionIndex"), valuesPrint.Sprint(acc.ElectionIndex))
if acc.InfoURL != "" && acc.InfoURL != "none" {
fmt.Printf("%s: %s\n", keysPrint.Sprintf(" ➥ info URL"), valuesPrint.Sprintf(acc.InfoURL))
fmt.Printf("%s: %s\n", keysPrint.Sprint(" ➥ info URL"), valuesPrint.Sprint(acc.InfoURL))
}
if acc.Metadata != nil {
accMetadata, err := json.MarshalIndent(acc.Metadata, "", " ")
if err != nil {
log.Debug("account metadata cannot be unmarshal")
} else {
fmt.Printf("%s:\n%s\n", keysPrint.Sprintf(" ➥ metadata"), valuesPrint.Sprintf("%s", accMetadata))
fmt.Printf("%s:\n%s\n", keysPrint.Sprint(" ➥ metadata"), valuesPrint.Sprint(string(accMetadata)))
}
}

Expand All @@ -268,11 +268,11 @@ func networkInfo(cli *VocdoniCLI) error {
if err != nil {
return err
}
fmt.Printf("%s: %s\n", keysPrint.Sprintf(" ➥ API host"), valuesPrint.Sprintf(cli.config.Host.Host))
fmt.Printf("%s: %s\n", keysPrint.Sprintf(" ➥ chainID"), valuesPrint.Sprintf(info.ID))
fmt.Printf("%s: %s\n", keysPrint.Sprintf(" ➥ height"), valuesPrint.Sprintf("%d", info.Height))
fmt.Printf("%s: %s\n", keysPrint.Sprintf(" ➥ block time"), valuesPrint.Sprintf("%v", info.BlockTime))
fmt.Printf("%s: %s\n", keysPrint.Sprintf(" ➥ timestamp"), valuesPrint.Sprintf("%d", info.Timestamp))
fmt.Printf("%s: %s\n", keysPrint.Sprint(" ➥ API host"), valuesPrint.Sprint(cli.config.Host.Host))
fmt.Printf("%s: %s\n", keysPrint.Sprint(" ➥ chainID"), valuesPrint.Sprint(info.ID))
fmt.Printf("%s: %s\n", keysPrint.Sprint(" ➥ height"), valuesPrint.Sprint(info.Height))
fmt.Printf("%s: %s\n", keysPrint.Sprint(" ➥ block time"), valuesPrint.Sprint(info.BlockTime))
fmt.Printf("%s: %s\n", keysPrint.Sprint(" ➥ timestamp"), valuesPrint.Sprint(info.Timestamp))
return nil
}

Expand Down Expand Up @@ -308,29 +308,29 @@ func bootStrapAccount(cli *VocdoniCLI) error {
if err != nil {
return err
}
infoPrint.Printf("trying to fetch faucet package from default remote service...\n")
infoPrint.Print("trying to fetch faucet package from default remote service...\n")
faucetPkg, err = apiclient.GetFaucetPackageFromDefaultService(cli.api.MyAddress().Hex(), info.ID)
if err != nil {
return err
}
infoPrint.Printf("got faucet package!")
infoPrint.Print("got faucet package!")
}

infoPrint.Printf("bootstraping account...\n")
infoPrint.Print("bootstraping account...\n")

txHash, err := cli.api.AccountBootstrap(faucetPkg, &api.AccountMetadata{
Name: map[string]string{"default": "vocdoni cli account " + cli.getCurrentAccount().Address.Hex()},
}, nil)
if err != nil {
return err
}
infoPrint.Printf("transaction sent! hash %s\n", txHash.String())
infoPrint.Printf("waiting for confirmation...")
infoPrint.Print("transaction sent! hash ", txHash.String(), "\n")
infoPrint.Print("waiting for confirmation...")
ok := cli.waitForTransaction(txHash)
if !ok {
return fmt.Errorf("transaction was not included")
}
infoPrint.Printf(" transaction confirmed!\n")
infoPrint.Print(" transaction confirmed!\n")
return nil
}

Expand Down Expand Up @@ -390,21 +390,21 @@ func transfer(cli *VocdoniCLI) error {
return err
}
if item == "N" {
log.Infof("transfer canceled")
log.Info("transfer canceled")
return nil
}

txHash, err := cli.api.Transfer(dstAddress, uint64(amount))
if err != nil {
return err
}
infoPrint.Printf("transaction sent! hash %s\n", txHash.String())
infoPrint.Printf("waiting for confirmation...")
infoPrint.Print("transaction sent! hash ", txHash.String(), "\n")
infoPrint.Print("waiting for confirmation...")
ok := cli.waitForTransaction(txHash)
if !ok {
return fmt.Errorf("transaction was not included")
}
infoPrint.Printf(" transaction confirmed!\n")
infoPrint.Print(" transaction confirmed!\n")
return nil
}

Expand Down Expand Up @@ -450,13 +450,13 @@ func faucetPkg(cli *VocdoniCLI) error {
if err != nil {
return err
}
infoPrint.Printf("faucet package for %s with amount %d: [ %s ]\n", to.Hex(), amount, base64.StdEncoding.EncodeToString(fpackageBytes))
infoPrint.Print("faucet package for ", to.Hex(), " with amount ", amount, ": [ ", base64.StdEncoding.EncodeToString(fpackageBytes), " ]\n")
return nil
}

func hostHandler(cli *VocdoniCLI) error {
validateFunc := func(url string) error {
log.Debugf("performing ping test to %s", url)
log.Debug("performing ping test to ", url)
_, err := http.NewRequest("GET", url+"/ping", http.NoBody)
return err
}
Expand All @@ -471,7 +471,7 @@ func hostHandler(cli *VocdoniCLI) error {
if err != nil {
return err
}
infoPrint.Printf("configuring API host to %s\n", host)
infoPrint.Print("configuring API host to ", host, "\n")
if err := cli.setHost(host); err != nil {
return err
}
Expand All @@ -489,7 +489,7 @@ func hostHandler(cli *VocdoniCLI) error {
}

func accountSetValidator(cli *VocdoniCLI) error {
infoPrint.Printf("enter the name and a public key of the validator, leave it bank for using the selected account\n")
infoPrint.Print("enter the name and a public key of the validator, leave it bank for using the selected account\n")

n := ui.Prompt{
Label: "name",
Expand Down Expand Up @@ -519,13 +519,13 @@ func accountSetValidator(cli *VocdoniCLI) error {
return err
}

infoPrint.Printf("transaction sent! hash %s\n", hash.String())
infoPrint.Printf("waiting for confirmation...")
infoPrint.Print("transaction sent! hash ", hash.String(), "\n")
infoPrint.Print("waiting for confirmation...")
ok := cli.waitForTransaction(hash)
if !ok {
return fmt.Errorf("transaction was not included")
}
infoPrint.Printf(" transaction confirmed!\n")
infoPrint.Print(" transaction confirmed!\n")

return nil
}
Expand All @@ -551,7 +551,7 @@ func accountSetMetadata(cli *VocdoniCLI) error {
}

if currentAccount.Metadata != nil {
log.Infof("account has metadata (%s) let's update it", currentAccount.InfoURL)
log.Info("account has metadata (", currentAccount.InfoURL, ") let's update it")
accMeta = *currentAccount.Metadata
}

Expand Down Expand Up @@ -600,21 +600,21 @@ func accountSetMetadata(cli *VocdoniCLI) error {
return err
}

infoPrint.Printf("set account metadata...\n")
infoPrint.Print("set account metadata...\n")
txHash, err := cli.api.AccountSetMetadata(&accMeta)
if err != nil {
return err
}
infoPrint.Printf("account transaction sent! hash is %s\n", txHash.String())
infoPrint.Printf("waiting for confirmation...\n")
infoPrint.Print("account transaction sent! hash is ", txHash.String(), "\n")
infoPrint.Print("waiting for confirmation...\n")
if !cli.waitForTransaction(txHash) {
return fmt.Errorf("transaction was not included")
}
return nil
}

func electionHandler(cli *VocdoniCLI) error {
infoPrint.Printf("preparing the election template...\n")
infoPrint.Print("preparing the election template...\n")
description := api.ElectionDescription{
Title: map[string]string{"default": "election title"},
Description: map[string]string{"default": "election description"},
Expand Down Expand Up @@ -691,12 +691,12 @@ func electionHandler(cli *VocdoniCLI) error {
return err
}

infoPrint.Printf("creating new election...\n")
infoPrint.Print("creating new election...\n")
electionID, err := cli.api.NewElection(&description, true)
if err != nil {
return err
}

infoPrint.Printf("election transaction sent! electionID is %s\n", electionID.String())
infoPrint.Print("election transaction sent! electionID is ", electionID.String(), "\n")
return nil
}
Loading

0 comments on commit b090324

Please sign in to comment.