From db981a67268c2c26cde4d178a485609f17646797 Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Thu, 19 Mar 2026 13:42:29 -0400 Subject: [PATCH 1/4] Various upgrades Follow up to #5. This upgrades: * `buf` to latest * `golangci-lint` to match buf's version, up to v2 * Fixes some minor lints * go.mod version to 1.25.0 (n-1) * Add 2026 to copyright years --- .golangci.yml | 104 +++++++++++++++----------- Makefile | 19 ++--- app.go | 2 +- app_error.go | 2 +- app_test.go | 2 +- app_unix.go | 2 +- app_windows.go | 2 +- appcmd/appcmd.go | 6 +- appcmd/appcmd_test.go | 2 +- appcmd/appcmdtesting/appcmdtesting.go | 6 +- appcmd/cobra.go | 2 +- appcmd/invalid_argument_error.go | 2 +- appcmd/positional_args.go | 2 +- appext/appext.go | 2 +- appext/builder.go | 2 +- appext/container.go | 2 +- appext/log_format.go | 2 +- appext/log_level.go | 2 +- appext/logger_container.go | 2 +- appext/name_container.go | 2 +- appext/name_container_unix_test.go | 2 +- arg_container.go | 2 +- container.go | 2 +- discard_reader.go | 2 +- env_container.go | 2 +- go.mod | 4 +- locked_writer.go | 2 +- stderr_container.go | 2 +- stdin_container.go | 2 +- stdout_container.go | 2 +- 30 files changed, 101 insertions(+), 88 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 778b1de..75f778f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,25 +1,6 @@ -linters-settings: - errcheck: - check-type-assertions: true - forbidigo: - forbid: - - '^fmt\.Print' - - '^log\.' - - '^print$' - - '^println$' - - '^panic$' - godox: - # TODO, OPT, etc. comments are fine to commit. Use FIXME comments for - # temporary hacks, and use godox to prevent committing them. - keywords: [FIXME] - varnamelen: - ignore-decls: - - T any - - i int - - wg sync.WaitGroup - - id string +version: "2" linters: - enable-all: true + default: all disable: - cyclop # covered by gocyclo - depguard # unnecessary for small libraries @@ -28,8 +9,6 @@ linters: - funlen # rely on code review to limit function length - gochecknoglobals # many exceptions - gocognit # dubious "cognitive overhead" quantification - - gofumpt # prefer standard gofmt - - goimports # rely on gci instead - inamedparam # not standard style - interfacebloat # many exceptions - ireturn # "accept interfaces, return structs" isn't ironclad @@ -43,25 +22,60 @@ linters: - thelper # we want to print out the whole stack - wrapcheck # don't _always_ need to wrap errors - wsl # generous whitespace violates house style -issues: - exclude-dirs-use-default: false - exclude-rules: - - linters: - - revive - text: "error.*capitalized" - - linters: - - stylecheck - text: "error.*capitalized" - - linters: - - stylecheck - path: appcmd/appcmd.go - text: "ST1005" - - linters: - - unparam - path: appext/name_container_unix_test.go - - linters: - - varnamelen - path: app.go - - linters: - - varnamelen - path: appext/builder.go + - noinlineerr # if err := ...; err != nil is idiomatic Go + - wsl_v5 # generous whitespace violates house style + settings: + errcheck: + check-type-assertions: true + forbidigo: + forbid: + - pattern: '^fmt\.Print' + - pattern: '^log\.' + - pattern: '^print$' + - pattern: '^println$' + - pattern: '^panic$' + godox: + # TODO, OPT, etc. comments are fine to commit. Use FIXME comments for + # temporary hacks, and use godox to prevent committing them. + keywords: [FIXME] + varnamelen: + ignore-decls: + - T any + - i int + - wg sync.WaitGroup + - id string + exclusions: + rules: + - linters: + - revive + text: "error.*capitalized" + - linters: + - staticcheck + text: "error.*capitalized" + - linters: + - staticcheck + # No need to require embedded fields from selector expression. + text: "QF1008" + - linters: + - staticcheck + # Whether or not to apply De Morgan's law is contextual. + text: "QF1001" + - linters: + - gosec + # G304: reading user-specified config/secret files is expected behavior. + path: appext/appext.go + text: "G304:" + - linters: + - gosec + # G301: 0755 is appropriate for application config directories. + path: appext/appext.go + text: "G301:" + - linters: + - unparam + path: appext/name_container_unix_test.go + - linters: + - varnamelen + path: app.go + - linters: + - varnamelen + path: appext/builder.go diff --git a/Makefile b/Makefile index e34626b..36c039d 100644 --- a/Makefile +++ b/Makefile @@ -9,14 +9,15 @@ MAKEFLAGS += --no-print-directory BIN := .tmp/bin export PATH := $(abspath $(BIN)):$(PATH) export GOBIN := $(abspath $(BIN)) -COPYRIGHT_YEARS := 2025 +COPYRIGHT_YEARS := 2025-2026 LICENSE_IGNORE := --ignore testdata/ -BUF_VERSION := v1.53.0 -GO_MOD_GOTOOLCHAIN := go1.24.3 -GOLANGCI_LINT_VERSION := v1.64.8 -# https://github.com/golangci/golangci-lint/issues/4837 -GOLANGCI_LINT_GOTOOLCHAIN := $(GO_MOD_GOTOOLCHAIN) +# https://github.com/bufbuild/buf/releases +BUF_VERSION := v1.66.1 +GOLANGCI_LINT_VERSION := v2.9.0 +# This version is the go toolchain version (which may be more specific than the module +# version) to ensure the build handles specific language features in newer toolchains. +GOLANGCILINT_GOTOOLCHAIN_VERSION := $(shell go env GOVERSION | sed 's/^go//') #GO_GET_PKGS := .PHONY: help @@ -48,11 +49,11 @@ install: ## Install all binaries .PHONY: lint lint: $(BIN)/golangci-lint ## Lint go vet ./... - GOTOOLCHAIN=$(GOLANGCI_LINT_GOTOOLCHAIN) golangci-lint run --modules-download-mode=readonly --timeout=3m0s + GOTOOLCHAIN=go$(GOLANGCILINT_GOTOOLCHAIN_VERSION) golangci-lint run --modules-download-mode=readonly --timeout=3m0s .PHONY: lintfix lintfix: $(BIN)/golangci-lint ## Automatically fix some lint errors - GOTOOLCHAIN=$(GOLANGCI_LINT_GOTOOLCHAIN) golangci-lint run --fix --modules-download-mode=readonly --timeout=3m0s + GOTOOLCHAIN=go$(GOLANGCILINT_GOTOOLCHAIN_VERSION) golangci-lint run --fix --modules-download-mode=readonly --timeout=3m0s .PHONY: generate generate: $(BIN)/license-header ## Regenerate code and licenses @@ -78,4 +79,4 @@ $(BIN)/license-header: Makefile $(BIN)/golangci-lint: Makefile @mkdir -p $(@D) - GOTOOLCHAIN=$(GOLANGCI_LINT_GOTOOLCHAIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) + GOTOOLCHAIN=go$(GOLANGCILINT_GOTOOLCHAIN_VERSION) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) diff --git a/app.go b/app.go index c0e8b4e..d0f944a 100644 --- a/app.go +++ b/app.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/app_error.go b/app_error.go index 7e8ef11..2b2493e 100644 --- a/app_error.go +++ b/app_error.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/app_test.go b/app_test.go index ae7e5cd..ea82f0b 100644 --- a/app_test.go +++ b/app_test.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/app_unix.go b/app_unix.go index 9b01087..b454735 100644 --- a/app_unix.go +++ b/app_unix.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/app_windows.go b/app_windows.go index 1d3a400..d179abc 100644 --- a/app_windows.go +++ b/app_windows.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appcmd/appcmd.go b/appcmd/appcmd.go index bb69359..2a498a3 100644 --- a/appcmd/appcmd.go +++ b/appcmd/appcmd.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -330,9 +330,9 @@ func commandToCobra( cobraCommand.Run = func(_ *cobra.Command, args []string) { printUsage(container, cobraCommand.UsageString()) if len(args) == 0 { - *runErrAddr = errors.New("Sub-command required.") + *runErrAddr = errors.New("sub-command required") } else { - *runErrAddr = fmt.Errorf("Unknown sub-command: %s", strings.Join(args, " ")) + *runErrAddr = fmt.Errorf("unknown sub-command: %s", strings.Join(args, " ")) } } for _, subCommand := range command.SubCommands { diff --git a/appcmd/appcmd_test.go b/appcmd/appcmd_test.go index 619f517..45363b6 100644 --- a/appcmd/appcmd_test.go +++ b/appcmd/appcmd_test.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appcmd/appcmdtesting/appcmdtesting.go b/appcmd/appcmdtesting/appcmdtesting.go index fd0d943..5b72cd7 100644 --- a/appcmd/appcmdtesting/appcmdtesting.go +++ b/appcmd/appcmdtesting/appcmdtesting.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -176,7 +176,7 @@ func WithStdout(stdout io.Writer) RunOption { } } -// WithStdout will attach the given stderr to write to. +// WithStderr will attach the given stderr to write to. func WithStderr(stderr io.Writer) RunOption { return func(runOptions *runOptions) { runOptions.stderr = stderr @@ -200,7 +200,7 @@ func WithExpectedStdout(expectedStdout string) RunOption { } } -// WithExpectedStdout will result in an error if the stderr does not exactly equal the given string. +// WithExpectedStderr will result in an error if the stderr does not exactly equal the given string. // // Note that this can be called with empty, which will result in Run verifying that the stderr is empty. func WithExpectedStderr(expectedStderr string) RunOption { diff --git a/appcmd/cobra.go b/appcmd/cobra.go index 211fb93..42aa5ab 100644 --- a/appcmd/cobra.go +++ b/appcmd/cobra.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appcmd/invalid_argument_error.go b/appcmd/invalid_argument_error.go index b653cb5..791ba77 100644 --- a/appcmd/invalid_argument_error.go +++ b/appcmd/invalid_argument_error.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appcmd/positional_args.go b/appcmd/positional_args.go index fb23d04..3bf0641 100644 --- a/appcmd/positional_args.go +++ b/appcmd/positional_args.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appext/appext.go b/appext/appext.go index 0362b41..599d16b 100644 --- a/appext/appext.go +++ b/appext/appext.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appext/builder.go b/appext/builder.go index c0dd35e..9aaa3cc 100644 --- a/appext/builder.go +++ b/appext/builder.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appext/container.go b/appext/container.go index 88ec902..9920f55 100644 --- a/appext/container.go +++ b/appext/container.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appext/log_format.go b/appext/log_format.go index b459ef7..a4b6f64 100644 --- a/appext/log_format.go +++ b/appext/log_format.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appext/log_level.go b/appext/log_level.go index 8f359c3..b8e77aa 100644 --- a/appext/log_level.go +++ b/appext/log_level.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appext/logger_container.go b/appext/logger_container.go index bc89d58..56e1acd 100644 --- a/appext/logger_container.go +++ b/appext/logger_container.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appext/name_container.go b/appext/name_container.go index 908bc35..88bf272 100644 --- a/appext/name_container.go +++ b/appext/name_container.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/appext/name_container_unix_test.go b/appext/name_container_unix_test.go index 7a5553c..24ef22e 100644 --- a/appext/name_container_unix_test.go +++ b/appext/name_container_unix_test.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/arg_container.go b/arg_container.go index 0f16929..3fdf97b 100644 --- a/arg_container.go +++ b/arg_container.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/container.go b/container.go index 65d71ea..15e458d 100644 --- a/container.go +++ b/container.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/discard_reader.go b/discard_reader.go index 47cd39f..a94d13d 100644 --- a/discard_reader.go +++ b/discard_reader.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/env_container.go b/env_container.go index 247f2e8..f6bf40b 100644 --- a/env_container.go +++ b/env_container.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/go.mod b/go.mod index 0f10033..b78f6fa 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module buf.build/go/app -go 1.23.0 - -toolchain go1.24.3 +go 1.25.0 require ( buf.build/go/interrupt v1.1.0 diff --git a/locked_writer.go b/locked_writer.go index eacdbe4..0c0ce90 100644 --- a/locked_writer.go +++ b/locked_writer.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/stderr_container.go b/stderr_container.go index defaab1..841f9b2 100644 --- a/stderr_container.go +++ b/stderr_container.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/stdin_container.go b/stdin_container.go index 78cdf5e..1931a0b 100644 --- a/stdin_container.go +++ b/stdin_container.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/stdout_container.go b/stdout_container.go index 81a27b8..43e0d4b 100644 --- a/stdout_container.go +++ b/stdout_container.go @@ -1,4 +1,4 @@ -// Copyright 2025 Buf Technologies, Inc. +// Copyright 2025-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From 530e5566f777950a8022e6bba17b00562982229b Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Thu, 19 Mar 2026 13:50:13 -0400 Subject: [PATCH 2/4] Run CI workflow on all pull requests --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1d56fa0..530fd24 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,7 +4,6 @@ on: branches: [main] tags: ['v*'] pull_request: - branches: [main] schedule: - cron: '15 22 * * *' workflow_dispatch: {} # support manual runs From 89b321ebc20e447dc748b426aaf9ff1aae19ff51 Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Fri, 20 Mar 2026 09:42:52 -0400 Subject: [PATCH 3/4] Remove `go mod edit -toolchain` from upgrade target --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 36c039d..ab7db53 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,6 @@ generate: $(BIN)/license-header ## Regenerate code and licenses .PHONY: upgrade upgrade: ## Upgrade dependencies - go mod edit -toolchain=$(GO_MOD_GOTOOLCHAIN) go get -u -t ./... $(GO_GET_PKGS) go mod tidy -v From eff454f1672fe342cf6febd6ef7e14f63433a52b Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Fri, 20 Mar 2026 09:47:08 -0400 Subject: [PATCH 4/4] Upgrade CI And use latest/previous names, similar to connect-go. --- .github/workflows/ci.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 530fd24..7c45202 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,11 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [1.23.x, 1.24.x] + go-version: + - name: latest + version: 1.26.x + - name: previous + version: 1.25.x steps: - name: Checkout Code uses: actions/checkout@v4 @@ -23,7 +27,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go-version }} + go-version: ${{ matrix.go-version.version }} - name: Test run: make test - name: Lint @@ -31,5 +35,5 @@ jobs: # conflicting guidance, run only on the most recent supported version. # For the same reason, only check generated code on the most recent # supported version. - if: matrix.go-version == '1.24.x' + if: matrix.go-version.name == 'latest' run: make checkgenerate && make lint