From 8c80e1c8dd8fc11a6da550069c30e90d213b4879 Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Tue, 26 Aug 2025 17:16:08 +0200 Subject: [PATCH 1/2] Enable the godot linter Signed-off-by: Arve Knudsen --- .golangci.yml | 2 +- config/http_config.go | 4 ++-- config/http_config_test.go | 2 +- expfmt/expfmt_test.go | 4 +--- model/metric.go | 4 ++-- model/time.go | 4 ++-- promslog/flag/flag.go | 2 +- promslog/slog.go | 2 +- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f22a4bcdf..3d97d7482 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -7,7 +7,7 @@ linters: - exptostd #- fatcontext #- gocritic - #- godot + - godot - govet - loggercheck - misspell diff --git a/config/http_config.go b/config/http_config.go index 5d3f1941b..5660cc31e 100644 --- a/config/http_config.go +++ b/config/http_config.go @@ -245,7 +245,7 @@ type OAuth2 struct { ProxyConfig `yaml:",inline"` } -// UnmarshalYAML implements the yaml.Unmarshaler interface +// UnmarshalYAML implements the yaml.Unmarshaler interface. func (o *OAuth2) UnmarshalYAML(unmarshal func(interface{}) error) error { type plain OAuth2 if err := unmarshal((*plain)(o)); err != nil { @@ -423,7 +423,7 @@ func (c *HTTPClientConfig) Validate() error { return nil } -// UnmarshalYAML implements the yaml.Unmarshaler interface +// UnmarshalYAML implements the yaml.Unmarshaler interface. func (c *HTTPClientConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { type plain HTTPClientConfig *c = DefaultHTTPClientConfig diff --git a/config/http_config_test.go b/config/http_config_test.go index 58d13b0dc..d959ab089 100644 --- a/config/http_config_test.go +++ b/config/http_config_test.go @@ -1748,7 +1748,7 @@ func TestUnmarshalEmptyURL(t *testing.T) { } } -// checks if u equals to &url.URL{} +// checks if u equals to &url.URL{}. func isEmptyNonNilURL(u *url.URL) bool { return u != nil && *u == url.URL{} } diff --git a/expfmt/expfmt_test.go b/expfmt/expfmt_test.go index 0a5ef55b9..e8a8ebba9 100644 --- a/expfmt/expfmt_test.go +++ b/expfmt/expfmt_test.go @@ -21,9 +21,7 @@ import ( "github.com/prometheus/common/model" ) -// Test Format to Escapting Scheme conversion -// Path: expfmt/expfmt_test.go -// Compare this snippet from expfmt/expfmt.go: +// Test Format to Escapting Scheme conversion. func TestToFormatType(t *testing.T) { tests := []struct { format Format diff --git a/model/metric.go b/model/metric.go index 2aa78900e..1cc7d7d3b 100644 --- a/model/metric.go +++ b/model/metric.go @@ -238,7 +238,7 @@ const ( // Accept header, the default NameEscapingScheme will be used. EscapingKey = "escaping" - // Possible values for Escaping Key: + // Possible values for Escaping Key. AllowUTF8 = "allow-utf-8" // No escaping required. EscapeUnderscores = "underscores" EscapeDots = "dots" @@ -470,7 +470,7 @@ func EscapeName(name string, scheme EscapingScheme) string { } } -// lower function taken from strconv.atoi +// lower function taken from strconv.atoi. func lower(c byte) byte { return c | ('x' - 'X') } diff --git a/model/time.go b/model/time.go index fed9e87b9..43e352a42 100644 --- a/model/time.go +++ b/model/time.go @@ -170,14 +170,14 @@ func (t *Time) UnmarshalJSON(b []byte) error { // This type should not propagate beyond the scope of input/output processing. type Duration time.Duration -// Set implements pflag/flag.Value +// Set implements pflag/flag.Value. func (d *Duration) Set(s string) error { var err error *d, err = ParseDuration(s) return err } -// Type implements pflag.Value +// Type implements pflag.Value. func (d *Duration) Type() string { return "duration" } diff --git a/promslog/flag/flag.go b/promslog/flag/flag.go index 85c67b250..40187cfcd 100644 --- a/promslog/flag/flag.go +++ b/promslog/flag/flag.go @@ -40,7 +40,7 @@ const FormatFlagName = "log.format" var FormatFlagHelp = "Output format of log messages. One of: [" + strings.Join(promslog.FormatFlagOptions, ", ") + "]" // AddFlags adds the flags used by this package to the Kingpin application. -// To use the default Kingpin application, call AddFlags(kingpin.CommandLine) +// To use the default Kingpin application, call AddFlags(kingpin.CommandLine). func AddFlags(a *kingpin.Application, config *promslog.Config) { config.Level = promslog.NewLevel() a.Flag(LevelFlagName, LevelFlagHelp). diff --git a/promslog/slog.go b/promslog/slog.go index 02370f175..33da53f82 100644 --- a/promslog/slog.go +++ b/promslog/slog.go @@ -138,7 +138,7 @@ func (f *Format) Set(s string) error { return nil } -// Config is a struct containing configurable settings for the logger +// Config is a struct containing configurable settings for the logger. type Config struct { Level *Level Format *Format From dc653734f7de8bb7af82a18dce551a3ad0453703 Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Tue, 26 Aug 2025 18:46:49 +0200 Subject: [PATCH 2/2] Update expfmt/expfmt_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Arve Knudsen --- expfmt/expfmt_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/expfmt/expfmt_test.go b/expfmt/expfmt_test.go index e8a8ebba9..7ac054f23 100644 --- a/expfmt/expfmt_test.go +++ b/expfmt/expfmt_test.go @@ -21,7 +21,7 @@ import ( "github.com/prometheus/common/model" ) -// Test Format to Escapting Scheme conversion. +// Test Format to Escaping Scheme conversion. func TestToFormatType(t *testing.T) { tests := []struct { format Format