Skip to content

Commit e28fbd6

Browse files
committedApr 4, 2025··
Enable more strict linter and fix issues
1 parent bb712a3 commit e28fbd6

File tree

8 files changed

+34
-24
lines changed

8 files changed

+34
-24
lines changed
 

‎.golangci.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "2"
1+
version: '2'
22

33
linters:
44
enable:
@@ -20,6 +20,9 @@ linters:
2020
- errcheck
2121

2222
settings:
23+
staticcheck:
24+
checks:
25+
- all
2326
gosec:
2427
excludes:
2528
- G104

‎expfmt.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (w ExpfmtWriter) WriteDuration(value time.Duration) {
110110
w.b.WriteByte('\n')
111111
}
112112

113-
// WriteDuration writes a bool and signals the end of the metric.
113+
// WriteBool writes a bool and signals the end of the metric.
114114
func (w ExpfmtWriter) WriteBool(value bool) {
115115
if value {
116116
w.b.WriteString(" 1\n")

‎internal/assert/difflib/difflib.go

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
// are no guarantees generated diffs are consumable by patch(1).
1616
//
1717
// Taken from https://github.com/pmezard/go-difflib see LICENSE.
18+
//
19+
//nolint:staticcheck
1820
package difflib
1921

2022
import (

‎internal/atomicx/atomicx.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package atomicx provides additional atomic types.
12
package atomicx
23

34
import (

‎internal/fasttime/fasttime.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// See: https://go.withmatt.com/fasttime
2+
//
3+
//nolint:staticcheck
24
package fasttime
35

46
import (

‎internal/syncx/doc.go

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package syncx provides additional synchronization primitives.
2+
package syncx

‎promhttp/promhttp.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"go.withmatt.com/metrics"
2525
)
2626

27-
// HTTP Content-Type header for this format.
27+
// ContentType is the HTTP Content-Type header for this format.
2828
const ContentType = "text/plain; version=0.0.4"
2929

3030
// Handler returns an http.Handler for the global metrics Set.

‎set_vec.go

+21-21
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (s *Set) NewSetVecWithTTL(label string, ttl time.Duration) *SetVec {
4444
return sv
4545
}
4646

47-
// WithLabelValues returns the Set for the corresponding label value.
47+
// WithLabelValue returns the Set for the corresponding label value.
4848
// If the combination of values is seen for the first time, a new Set
4949
// is created.
5050
//
@@ -53,20 +53,20 @@ func (s *Set) NewSetVecWithTTL(label string, ttl time.Duration) *SetVec {
5353
// the returned Set alive if necessary.
5454
//
5555
// See [Set.KeepAlive] to manually keep a specific Set alive.
56-
func (s *SetVec) WithLabelValue(value string) *Set {
57-
hash := hashFinish(s.partialHash, value)
56+
func (sv *SetVec) WithLabelValue(value string) *Set {
57+
hash := hashFinish(sv.partialHash, value)
5858

59-
set, ok := s.s.setsByHash.Load(hash)
59+
set, ok := sv.s.setsByHash.Load(hash)
6060
if !ok {
61-
set = s.s.loadOrStoreSetFromVec(hash, s.ttl, s.label, value)
61+
set = sv.s.loadOrStoreSetFromVec(hash, sv.ttl, sv.label, value)
6262
}
6363
set.KeepAlive()
6464
return set
6565
}
6666

6767
// RemoveByLabelValue removes the Set for the corresponding label value.
68-
func (s *SetVec) RemoveByLabelValue(value string) {
69-
s.s.setsByHash.Delete(hashFinish(s.partialHash, value))
68+
func (sv *SetVec) RemoveByLabelValue(value string) {
69+
sv.s.setsByHash.Delete(hashFinish(sv.partialHash, value))
7070
}
7171

7272
// NewUint64Vec creates a new [Uint64Vec] with the supplied name.
@@ -83,13 +83,13 @@ func (sv *SetVec) NewUint64Vec(family string, labels ...string) *Uint64Vec {
8383
// The returned Uint64 is safe to use from concurrent goroutines.
8484
//
8585
// This will panic if values are invalid or already registered.
86-
func (s *SetVec) NewUint64(family string, value string, tags ...string) *Uint64 {
87-
return s.WithLabelValue(value).NewUint64(family, tags...)
86+
func (sv *SetVec) NewUint64(family string, value string, tags ...string) *Uint64 {
87+
return sv.WithLabelValue(value).NewUint64(family, tags...)
8888
}
8989

9090
// NewCounter is an alias for [SetVec.NewUint64].
91-
func (s *SetVec) NewCounter(family string, value string, tags ...string) *Uint64 {
92-
return s.WithLabelValue(value).NewCounter(family, tags...)
91+
func (sv *SetVec) NewCounter(family string, value string, tags ...string) *Uint64 {
92+
return sv.WithLabelValue(value).NewCounter(family, tags...)
9393
}
9494

9595
// NewInt64Vec creates a new [Int64Vec] with the supplied name.
@@ -106,8 +106,8 @@ func (sv *SetVec) NewInt64Vec(family string, labels ...string) *Int64Vec {
106106
// The returned Int64 is safe to use from concurrent goroutines.
107107
//
108108
// This will panic if values are invalid or already registered.
109-
func (s *SetVec) NewInt64(family string, value string, tags ...string) *Int64 {
110-
return s.WithLabelValue(value).NewInt64(family, tags...)
109+
func (sv *SetVec) NewInt64(family string, value string, tags ...string) *Int64 {
110+
return sv.WithLabelValue(value).NewInt64(family, tags...)
111111
}
112112

113113
// NewFloat64Vec creates a new [Float64Vec] with the supplied name.
@@ -124,8 +124,8 @@ func (sv *SetVec) NewFloat64Vec(family string, labels ...string) *Float64Vec {
124124
// The returned Float64 is safe to use from concurrent goroutines.
125125
//
126126
// This will panic if values are invalid or already registered.
127-
func (s *SetVec) NewFloat64(family string, value string, tags ...string) *Float64 {
128-
return s.WithLabelValue(value).NewFloat64(family, tags...)
127+
func (sv *SetVec) NewFloat64(family string, value string, tags ...string) *Float64 {
128+
return sv.WithLabelValue(value).NewFloat64(family, tags...)
129129
}
130130

131131
// NewFixedHistogram creates and returns new FixedHistogram using the label from the SetVec.
@@ -137,16 +137,16 @@ func (s *SetVec) NewFloat64(family string, value string, tags ...string) *Float6
137137
// The returned FixedHistogram is safe to use from concurrent goroutines.
138138
//
139139
// This will panic if values are invalid or already registered.
140-
func (s *SetVec) NewFixedHistogram(family string, buckets []float64, value string, tags ...string) *FixedHistogram {
141-
return s.WithLabelValue(value).NewFixedHistogram(family, buckets, tags...)
140+
func (sv *SetVec) NewFixedHistogram(family string, buckets []float64, value string, tags ...string) *FixedHistogram {
141+
return sv.WithLabelValue(value).NewFixedHistogram(family, buckets, tags...)
142142
}
143143

144144
// NewFixedHistogramVec creates a new [FixedHistogramVec] with the supplied opt.
145-
func (s *SetVec) NewFixedHistogramVec(family string, buckets []float64, labels ...string) *FixedHistogramVec {
145+
func (sv *SetVec) NewFixedHistogramVec(family string, buckets []float64, labels ...string) *FixedHistogramVec {
146146
buckets = getBuckets(buckets)
147147

148148
return &FixedHistogramVec{
149-
commonVec: getCommonVecSetVec(s, family, labels),
149+
commonVec: getCommonVecSetVec(sv, family, labels),
150150
buckets: buckets,
151151
labels: labelsForBuckets(buckets),
152152
}
@@ -161,8 +161,8 @@ func (s *SetVec) NewFixedHistogramVec(family string, buckets []float64, labels .
161161
// The returned Histogram is safe to use from concurrent goroutines.
162162
//
163163
// This will panic if values are invalid or already registered.
164-
func (s *SetVec) NewHistogram(family string, value string, tags ...string) *Histogram {
165-
return s.WithLabelValue(value).NewHistogram(family, tags...)
164+
func (sv *SetVec) NewHistogram(family string, value string, tags ...string) *Histogram {
165+
return sv.WithLabelValue(value).NewHistogram(family, tags...)
166166
}
167167

168168
// NewHistogramVec creates a new [HistogramVec] with the supplied name.

0 commit comments

Comments
 (0)