From 8d407dd3ad321b655b72160d6a8eaa8103b1ab86 Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Thu, 22 Oct 2026 22:05:45 +0000 Subject: [PATCH] *: bump go version Signed-off-by: Wei Fu --- .github/workflows/ci.yml | 9 +++++---- .go-version | 1 + .golangci.yml | 29 ++++++++++++++++++++++------- Dockerfile | 3 ++- Makefile | 3 ++- cmd/kperf/commands/runner/runner.go | 2 +- go.mod | 4 +--- request/random.go | 5 +---- 8 files changed, 35 insertions(+), 21 deletions(-) create mode 100644 .go-version diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fb9cf26..08a70c2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,10 +9,11 @@ jobs: - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0 - uses: actions/setup-go@7b8cf10d4e4a01d4992d18a89f4d7dc5a3e6d6f4 # v4.3.0 with: - go-version: "1.21" + go-version-file: ".go-version" - name: golangci-lint - uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 + uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 with: + version: v2.15.0 args: --config .golangci.yml --timeout=8m test: @@ -21,7 +22,7 @@ jobs: - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0 - uses: actions/setup-go@7b8cf10d4e4a01d4992d18a89f4d7dc5a3e6d6f4 # v4.3.0 with: - go-version: "1.21" + go-version-file: ".go-version" - name: test run: make test @@ -31,7 +32,7 @@ jobs: - uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0 - uses: actions/setup-go@7b8cf10d4e4a01d4992d18a89f4d7dc5a3e6d6f4 # v4.3.0 with: - go-version: "1.21" + go-version-file: ".go-version" - name: build run: make build - name: image-build diff --git a/.go-version b/.go-version new file mode 100644 index 00000000..63d92c7f --- /dev/null +++ b/.go-version @@ -0,0 +1 @@ +1.26.10 diff --git a/.golangci.yml b/.golangci.yml index 120a8b6a..bf961a7a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,14 +1,29 @@ +version: "2" linters: enable: - - gofmt - - goimports - gosec - - ineffassign - misspell - nolintlint - revive - - staticcheck - unconvert - - unused - - vet - - errcheck + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/Dockerfile b/Dockerfile index 0c8905fe..6c06b04e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM golang:1.22 AS build-stage +ARG GO_VERSION +FROM golang:${GO_VERSION} AS build-stage WORKDIR /gomod COPY go.mod go.sum ./ diff --git a/Makefile b/Makefile index 9d75c576..8f94b01d 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ GO_BUILDTAGS = -tags "osusergo netgo static_build" IMAGE_REPO ?= localhost:5000 IMAGE_TAG ?= latest IMAGE_NAME = $(IMAGE_REPO)/kperf:$(IMAGE_TAG) +GO_VERSION := $(strip $(shell cat .go-version)) BINARIES=$(addprefix bin/,$(COMMANDS)) CONTRIB_BINARIES=$(addprefix bin/contrib/,$(CONTRIB_COMMANDS)) @@ -38,7 +39,7 @@ install: ## install binaries image-build: ## build image @echo building ${IMAGE_NAME} - @docker build . -t ${IMAGE_NAME} + @docker build --build-arg GO_VERSION=${GO_VERSION} . -t ${IMAGE_NAME} image-push: image-build ## push image @echo pushing ${IMAGE_NAME} diff --git a/cmd/kperf/commands/runner/runner.go b/cmd/kperf/commands/runner/runner.go index 6b19dd15..47c1551e 100644 --- a/cmd/kperf/commands/runner/runner.go +++ b/cmd/kperf/commands/runner/runner.go @@ -124,7 +124,7 @@ var runCommand = cli.Command{ return err } - var f *os.File = os.Stdout + f := os.Stdout outputFilePath := cliCtx.String("result") if outputFilePath != "" { outputFileDir := filepath.Dir(outputFilePath) diff --git a/go.mod b/go.mod index 586161d6..cbce2c13 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/Azure/kperf -go 1.22.0 - -toolchain go1.22.2 +go 1.26.0 require ( github.com/google/uuid v1.6.0 diff --git a/request/random.go b/request/random.go index a5a88a94..070133fa 100644 --- a/request/random.go +++ b/request/random.go @@ -90,10 +90,7 @@ func (r *WeightedRandomRequests) Run(ctx context.Context, total int) { r.wg.Add(1) sum := 0 - for { - if total > 0 && sum >= total { - break - } + for total <= 0 || sum < total { builder := r.randomPick() select { case r.reqBuilderCh <- builder: