mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2025-06-21 10:08:50 +00:00
Update Go
* Update Go build to 1.24. * Update minimum Go to 1.23.0. * Update golangci-lint to v2. * Fixup linter issues. Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
parent
e1cef5e7a7
commit
dbf1dba353
9 changed files with 43 additions and 33 deletions
|
@ -5,7 +5,7 @@ executors:
|
|||
# Whenever the Go version is updated here, .promu.yml should also be updated.
|
||||
golang:
|
||||
docker:
|
||||
- image: cimg/go:1.23
|
||||
- image: cimg/go:1.24
|
||||
jobs:
|
||||
test:
|
||||
executor: golang
|
||||
|
|
4
.github/workflows/golangci-lint.yml
vendored
4
.github/workflows/golangci-lint.yml
vendored
|
@ -33,7 +33,7 @@ jobs:
|
|||
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
|
||||
if: github.repository == 'prometheus/snmp_exporter'
|
||||
- name: Lint
|
||||
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
|
||||
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
|
||||
with:
|
||||
args: --verbose
|
||||
version: v1.64.6
|
||||
version: v2.0.2
|
||||
|
|
|
@ -1,26 +1,36 @@
|
|||
version: "2"
|
||||
run:
|
||||
issues-exit-code: 1
|
||||
tests: true
|
||||
linters:
|
||||
enable:
|
||||
- nakedret
|
||||
- whitespace
|
||||
disable:
|
||||
- errcheck
|
||||
enable:
|
||||
- goimports
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- nakedret
|
||||
- staticcheck
|
||||
- unused
|
||||
- whitespace
|
||||
linters-settings:
|
||||
govet:
|
||||
enable-all: true
|
||||
disable:
|
||||
- fieldalignment
|
||||
settings:
|
||||
govet:
|
||||
disable:
|
||||
- fieldalignment
|
||||
enable-all: true
|
||||
exclusions:
|
||||
generated: lax
|
||||
rules:
|
||||
- path: (.+)\.go$
|
||||
text: 'shadow: declaration of "err" shadows declaration at line (\d+)'
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
issues:
|
||||
exclude-use-default: false
|
||||
exclude:
|
||||
- 'shadow: declaration of "err" shadows declaration at line (\d+)'
|
||||
max-issues-per-linter: 0
|
||||
max-same-issues: 0
|
||||
formatters:
|
||||
enable:
|
||||
- goimports
|
||||
exclusions:
|
||||
generated: lax
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
go:
|
||||
# Whenever the Go version is updated here, .circle/config.yml should also
|
||||
# be updated.
|
||||
version: 1.23
|
||||
version: 1.24
|
||||
repository:
|
||||
path: github.com/prometheus/statsd_exporter
|
||||
build:
|
||||
|
|
|
@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
|
|||
SKIP_GOLANGCI_LINT :=
|
||||
GOLANGCI_LINT :=
|
||||
GOLANGCI_LINT_OPTS ?=
|
||||
GOLANGCI_LINT_VERSION ?= v1.64.6
|
||||
GOLANGCI_LINT_VERSION ?= v2.0.2
|
||||
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
|
||||
# windows isn't included here because of the path separator being different.
|
||||
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
|||
module github.com/prometheus/statsd_exporter
|
||||
|
||||
go 1.22
|
||||
go 1.23.0
|
||||
|
||||
require (
|
||||
github.com/alecthomas/kingpin/v2 v2.4.0
|
||||
|
|
|
@ -31,18 +31,18 @@ func (f *FSM) DumpFSM(w io.Writer) {
|
|||
for idx < len(states) {
|
||||
for field, transition := range states[idx].transitions {
|
||||
states[len(states)] = transition
|
||||
w.Write([]byte(fmt.Sprintf("%d -> %d [label = \"%s\"];\n", idx, len(states)-1, field)))
|
||||
fmt.Fprintf(w, "%d -> %d [label = \"%s\"];\n", idx, len(states)-1, field)
|
||||
if idx == 0 {
|
||||
// color for metric types
|
||||
w.Write([]byte(fmt.Sprintf("%d [color=\"#D6B656\",fillcolor=\"#FFF2CC\"];\n", len(states)-1)))
|
||||
fmt.Fprintf(w, "%d [color=\"#D6B656\",fillcolor=\"#FFF2CC\"];\n", len(states)-1)
|
||||
} else if len(transition.transitions) == 0 {
|
||||
// color for end state
|
||||
w.Write([]byte(fmt.Sprintf("%d [color=\"#82B366\",fillcolor=\"#D5E8D4\"];\n", len(states)-1)))
|
||||
fmt.Fprintf(w, "%d [color=\"#82B366\",fillcolor=\"#D5E8D4\"];\n", len(states)-1)
|
||||
}
|
||||
}
|
||||
idx++
|
||||
}
|
||||
// color for start state
|
||||
w.Write([]byte(fmt.Sprintln("0 [color=\"#a94442\",fillcolor=\"#f2dede\"];")))
|
||||
fmt.Fprintln(w, "0 [color=\"#a94442\",fillcolor=\"#f2dede\"];")
|
||||
w.Write([]byte("}"))
|
||||
}
|
||||
|
|
|
@ -46,9 +46,9 @@ func NewTemplateFormatter(template string, captureCount int) *TemplateFormatter
|
|||
if err != nil || idx > captureCount || idx < 1 {
|
||||
// if index larger than captured count or using unsupported named capture group,
|
||||
// replace with empty string
|
||||
valueFormatter = strings.Replace(valueFormatter, match[0], "", -1)
|
||||
valueFormatter = strings.ReplaceAll(valueFormatter, match[0], "")
|
||||
} else {
|
||||
valueFormatter = strings.Replace(valueFormatter, match[0], "%s", -1)
|
||||
valueFormatter = strings.ReplaceAll(valueFormatter, match[0], "%s")
|
||||
// note: the regex reference variable $? starts from 1
|
||||
indexes = append(indexes, idx-1)
|
||||
}
|
||||
|
|
|
@ -243,8 +243,8 @@ func TestIfNeedBacktracking(mappings []string, orderingDisabled bool, logger *sl
|
|||
l := len(strings.Split(mapping, "."))
|
||||
ruleByLength[l] = append(ruleByLength[l], mapping)
|
||||
|
||||
metricRe := strings.Replace(mapping, ".", "\\.", -1)
|
||||
metricRe = strings.Replace(metricRe, "*", "([^.]*)", -1)
|
||||
metricRe := strings.ReplaceAll(mapping, ".", "\\.")
|
||||
metricRe = strings.ReplaceAll(metricRe, "*", "([^.]*)")
|
||||
regex, err := regexp.Compile("^" + metricRe + "$")
|
||||
if err != nil {
|
||||
logger.Warn("Invalid match, cannot compile regex in mapping", "mapping", mapping, "err", err)
|
||||
|
@ -272,8 +272,8 @@ func TestIfNeedBacktracking(mappings []string, orderingDisabled bool, logger *sl
|
|||
}
|
||||
// translate the substring of r1 from 0 to the index of current * into regex
|
||||
// A.B.C.*.E.* will becomes ^A\.B\.C\. and ^A\.B\.C\.\*\.E\.
|
||||
reStr := strings.Replace(r1[:index], ".", "\\.", -1)
|
||||
reStr = strings.Replace(reStr, "*", "\\*", -1)
|
||||
reStr := strings.ReplaceAll(r1[:index], ".", "\\.")
|
||||
reStr = strings.ReplaceAll(reStr, "*", "\\*")
|
||||
re := regexp.MustCompile("^" + reStr)
|
||||
for i2, r2 := range rules {
|
||||
if i2 == i1 {
|
||||
|
|
Loading…
Reference in a new issue