From 2fb97321209332cf8acd85ab18a9d8dc5ea607c1 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Fri, 23 Oct 2026 20:53:44 +0100 Subject: [PATCH 1/8] ci: modernize Go tooling and CI Keeping the lint tool current preserves useful feedback during maintenance without forcing a module migration on this GOPATH-only package. Testing supported and current Go versions catches compatibility and toolchain regressions before release. --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 2 +- statsd_test.go | 11 ++++----- 3 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f26460a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: Go CI + +on: + push: + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + test: + name: Go ${{ matrix.go-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + go-version: ["1.13", "stable"] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: go/src/github.com/multiplay/statsd + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version: ${{ matrix.go-version }} + check-latest: true + cache: false + - name: Test + working-directory: go/src/github.com/multiplay/statsd + env: + GO111MODULE: off + GOPATH: ${{ github.workspace }}/go + GOMAXPROCS: 2 + run: go test -p 2 -race -timeout=10s ./... + - name: Vet + working-directory: go/src/github.com/multiplay/statsd + env: + GO111MODULE: off + GOPATH: ${{ github.workspace }}/go + GOMAXPROCS: 2 + run: go vet -p 2 ./... + - name: Build + working-directory: go/src/github.com/multiplay/statsd + env: + GO111MODULE: off + GOPATH: ${{ github.workspace }}/go + GOMAXPROCS: 2 + run: go build -p 2 ./... diff --git a/.travis.yml b/.travis.yml index 8670c48..2dfe6a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ go: - master install: - - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.6 + - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/v2.15.0/install.sh | sh -s -- -b "$(go env GOPATH)/bin" v2.15.0 script: - go test -v -race -timeout=10s ./... diff --git a/statsd_test.go b/statsd_test.go index fc7ffe8..65849ad 100644 --- a/statsd_test.go +++ b/statsd_test.go @@ -4,7 +4,6 @@ import ( "bytes" "errors" "io" - "io/ioutil" "net" "sync" "testing" @@ -203,7 +202,9 @@ func TestOddTagsArgs(t *testing.T) { } }() - _, _ = New(TagsFormat(InfluxDB), Tags("tag1")) + oddTags := []string{"tag1"} + //nolint:staticcheck // The odd tag count is the behavior under test. + _, _ = New(TagsFormat(InfluxDB), Tags(oddTags...)) t.Fatal("A panic should occur") } @@ -519,14 +520,14 @@ func newServer(t testing.TB, network, addr string, f func([]byte)) *server { s.closed <- true return } - p, err := ioutil.ReadAll(conn) - if err != nil { + var p bytes.Buffer + if _, err := io.Copy(&p, conn); err != nil { t.Fatal(err) } if err := conn.Close(); err != nil { t.Fatal(err) } - f(p) + f(p.Bytes()) } }() default: From 6097b0dc4b3e7082955d65c0a5dc223e1a401f86 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Sat, 24 Oct 2026 11:45:24 +0100 Subject: [PATCH 2/8] chore: adopt v2 modules and modern Go CI Make the v2 package usable through Go modules without requiring a GOPATH checkout or changing its public API. Travis is no longer used. Cover the stable and oldstable Go releases with GitHub Actions to keep validation focused on supported toolchains. --- .github/workflows/ci.yml | 21 +++------------------ .travis.yml | 12 ------------ README.md | 8 +++++++- examples_test.go | 2 +- go.mod | 3 +++ 5 files changed, 14 insertions(+), 32 deletions(-) delete mode 100644 .travis.yml create mode 100644 go.mod diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f26460a..72ae0c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,37 +12,22 @@ jobs: test: name: Go ${{ matrix.go-version }} runs-on: ubuntu-latest + env: + GOMAXPROCS: 2 strategy: fail-fast: false matrix: - go-version: ["1.13", "stable"] + go-version: ["stable", "oldstable"] steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - path: go/src/github.com/multiplay/statsd - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version: ${{ matrix.go-version }} check-latest: true cache: false - name: Test - working-directory: go/src/github.com/multiplay/statsd - env: - GO111MODULE: off - GOPATH: ${{ github.workspace }}/go - GOMAXPROCS: 2 run: go test -p 2 -race -timeout=10s ./... - name: Vet - working-directory: go/src/github.com/multiplay/statsd - env: - GO111MODULE: off - GOPATH: ${{ github.workspace }}/go - GOMAXPROCS: 2 run: go vet -p 2 ./... - name: Build - working-directory: go/src/github.com/multiplay/statsd - env: - GO111MODULE: off - GOPATH: ${{ github.workspace }}/go - GOMAXPROCS: 2 run: go build -p 2 ./... diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2dfe6a9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: go - -go: - - 1.x - - master - -install: - - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/v2.15.0/install.sh | sh -s -- -b "$(go env GOPATH)/bin" v2.15.0 - -script: - - go test -v -race -timeout=10s ./... - - golangci-lint run diff --git a/README.md b/README.md index 3afc3d5..d1e8ba6 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,13 @@ This is a fork of a [dead statsd client project](https://github.com/alexcesaro/s ## Download - go get github.com/multiplay/statsd + go get github.com/rocketsciencegg/statsd/v2 + +Import the v2 module in your Go code: + +```go +import "github.com/rocketsciencegg/statsd/v2" +``` ## License diff --git a/examples_test.go b/examples_test.go index 45ff0fd..8186112 100644 --- a/examples_test.go +++ b/examples_test.go @@ -5,7 +5,7 @@ import ( "runtime" "time" - "github.com/multiplay/statsd" + "github.com/rocketsciencegg/statsd/v2" ) var ( diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..7cb7e20 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/rocketsciencegg/statsd/v2 + +go 1.13 From d8cf0e54f4520c1b07d779fcea9da1021526d828 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Sat, 24 Oct 2026 11:52:35 +0100 Subject: [PATCH 3/8] chore: simplify CI and test input handling Let hosted CI use the default Go concurrency and setup-go caching instead of carrying unnecessary overrides. Use the standard read helper to keep test input handling idiomatic. Require Go 1.16 to match the standard library API used by the tests. --- .github/workflows/ci.yml | 9 +++------ go.mod | 2 +- statsd_test.go | 6 +++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72ae0c6..4d7b25c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,6 @@ jobs: test: name: Go ${{ matrix.go-version }} runs-on: ubuntu-latest - env: - GOMAXPROCS: 2 strategy: fail-fast: false matrix: @@ -24,10 +22,9 @@ jobs: with: go-version: ${{ matrix.go-version }} check-latest: true - cache: false - name: Test - run: go test -p 2 -race -timeout=10s ./... + run: go test -race -timeout=10s ./... - name: Vet - run: go vet -p 2 ./... + run: go vet ./... - name: Build - run: go build -p 2 ./... + run: go build ./... diff --git a/go.mod b/go.mod index 7cb7e20..27c2048 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/rocketsciencegg/statsd/v2 -go 1.13 +go 1.16 diff --git a/statsd_test.go b/statsd_test.go index 65849ad..1826568 100644 --- a/statsd_test.go +++ b/statsd_test.go @@ -520,14 +520,14 @@ func newServer(t testing.TB, network, addr string, f func([]byte)) *server { s.closed <- true return } - var p bytes.Buffer - if _, err := io.Copy(&p, conn); err != nil { + p, err := io.ReadAll(conn) + if err != nil { t.Fatal(err) } if err := conn.Close(); err != nil { t.Fatal(err) } - f(p.Bytes()) + f(p) } }() default: From e8d0b07a3cfe20e234b91d3c35f14b58e078dbf1 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Sat, 24 Oct 2026 11:55:43 +0100 Subject: [PATCH 4/8] test: restore direct odd-tag panic case Keep the intentional invalid input obvious in the panic regression test. The removed Travis lint job no longer needs a suppression. --- statsd_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/statsd_test.go b/statsd_test.go index 1826568..d33dd2a 100644 --- a/statsd_test.go +++ b/statsd_test.go @@ -202,9 +202,7 @@ func TestOddTagsArgs(t *testing.T) { } }() - oddTags := []string{"tag1"} - //nolint:staticcheck // The odd tag count is the behavior under test. - _, _ = New(TagsFormat(InfluxDB), Tags(oddTags...)) + _, _ = New(TagsFormat(InfluxDB), Tags("tag1")) t.Fatal("A panic should occur") } From ce70c55ce763de8b2ab1b38ca411d7383320de77 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Sat, 24 Oct 2026 11:59:13 +0100 Subject: [PATCH 5/8] ci: enable golangci-lint on stable Go Catch regressions during review without broad cleanup or weakening checks across the package. Exclude only the intentional odd-tag panic case so its invalid input remains explicit while other static analysis stays enabled. --- .github/workflows/ci.yml | 5 +++++ .golangci.yml | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .golangci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d7b25c..1fc821c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,3 +28,8 @@ jobs: run: go vet ./... - name: Build run: go build ./... + - name: Lint + if: matrix.go-version == 'stable' + uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 + with: + version: v2.15.0 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..d122659 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,10 @@ +version: "2" +linters: + exclusions: + rules: + # This regression test intentionally passes an odd number of tags. + - path: '(^|/)statsd_test\.go$' + linters: + - staticcheck + text: '^SA5012:' + source: 'Tags\("tag1"\)' From 8e26872868f329b5bdc4351676376261d4598b34 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Sat, 24 Oct 2026 12:03:13 +0100 Subject: [PATCH 6/8] ci: align workflow hygiene with mp-go Catch formatting, module drift, and inconsistent PR titles during review instead of relying on manual checks. Avoid redundant runs and cancel superseded work while preserving CI through the planned default branch rename from master to main. --- .github/workflows/ci.yml | 17 ++++++++++++++ .github/workflows/lint-pr-title.yml | 36 +++++++++++++++++++++++++++++ doc.go | 12 ++++------ 3 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/lint-pr-title.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fc821c..7a4f8f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,12 +2,19 @@ name: Go CI on: push: + branches: + - master + - main pull_request: workflow_dispatch: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: test: name: Go ${{ matrix.go-version }} @@ -22,6 +29,16 @@ jobs: with: go-version: ${{ matrix.go-version }} check-latest: true + - name: Check formatting + run: | + unformatted="$(gofmt -l .)" + if [ -n "$unformatted" ]; then + printf 'Run gofmt on:\n%s\n' "$unformatted" + exit 1 + fi + - name: Check module tidiness + if: matrix.go-version == 'stable' + run: go mod tidy -diff - name: Test run: go test -race -timeout=10s ./... - name: Vet diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml new file mode 100644 index 0000000..1493a93 --- /dev/null +++ b/.github/workflows/lint-pr-title.yml @@ -0,0 +1,36 @@ +name: Lint PR Title + +on: + pull_request: + types: + - opened + - reopened + - edited + - synchronize + +permissions: + pull-requests: read + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: | + feat + fix + docs + style + refactor + perf + test + build + ci + chore + revert + security + subjectPattern: '^[a-z].+$' + subjectPatternError: 'The description must start with a lowercase letter.' diff --git a/doc.go b/doc.go index bb7b986..0489876 100644 --- a/doc.go +++ b/doc.go @@ -1,8 +1,7 @@ /* Package statsd is a simple and efficient StatsD client. - -Options +# Options Use options to configure the Client: target host/port, sampling rate, tags, etc. @@ -12,13 +11,12 @@ rate), you should use the Clone() method of the Client. Because when cloning a Client, the same connection is reused so this is way cheaper and more efficient than creating another Client using New(). - -Internals +# Internals Client's methods buffer metrics. The buffer is flushed when either: - - the background goroutine flushes the buffer (every 100ms by default) - - the buffer is full (1440 bytes by default so that IP packets are not - fragmented) + - the background goroutine flushes the buffer (every 100ms by default) + - the buffer is full (1440 bytes by default so that IP packets are not + fragmented) The background goroutine can be disabled using the FlushPeriod(0) option. From dd47ac8f62283b3f4ff9a47ff7ef84124b3d783e Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Sat, 24 Oct 2026 12:08:44 +0100 Subject: [PATCH 7/8] ci: drop master branch compatibility The default branch is now main, so the temporary compatibility trigger is no longer needed. --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a4f8f7..18191d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,6 @@ name: Go CI on: push: branches: - - master - main pull_request: workflow_dispatch: From 9bb74d2c7242cbf014fcf3bd69345ddc28067ac2 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Sat, 24 Oct 2026 12:11:03 +0100 Subject: [PATCH 8/8] test: keep panic lint suppression inline Document the intentional invalid input at the call site instead of maintaining a separate lint exclusion configuration. --- .golangci.yml | 10 ---------- statsd_test.go | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index d122659..0000000 --- a/.golangci.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: "2" -linters: - exclusions: - rules: - # This regression test intentionally passes an odd number of tags. - - path: '(^|/)statsd_test\.go$' - linters: - - staticcheck - text: '^SA5012:' - source: 'Tags\("tag1"\)' diff --git a/statsd_test.go b/statsd_test.go index d33dd2a..42c2681 100644 --- a/statsd_test.go +++ b/statsd_test.go @@ -202,7 +202,7 @@ func TestOddTagsArgs(t *testing.T) { } }() - _, _ = New(TagsFormat(InfluxDB), Tags("tag1")) + _, _ = New(TagsFormat(InfluxDB), Tags("tag1")) //nolint:staticcheck // Intentionally pass an odd tag count to test the panic. t.Fatal("A panic should occur") }