From eab8ebbe1199a87e1ae8446741bf758312fb8d76 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 11 Jul 2022 19:21:59 +0300 Subject: [PATCH] all: `make fmt` via the upcoming Go1.19 --- app/vmalert/notifier/config.go | 5 +++-- app/vmalert/notifier/init.go | 5 +++-- app/vmctl/vm/timeseries.go | 2 +- app/vmselect/prometheus/prometheus.go | 2 -- app/vmselect/searchutils/searchutils.go | 9 +++++--- app/vmui/packages/vmui/web/main.go | 3 ++- lib/flagutil/array.go | 7 +++---- lib/leveledbytebufferpool/pool.go | 10 ++++----- lib/metricsql/doc.go | 1 - .../csvimport/column_descriptor.go | 16 +++++++------- lib/storage/partition_search.go | 2 +- lib/storage/tag_filters.go | 21 ++++++++++--------- 12 files changed, 43 insertions(+), 40 deletions(-) diff --git a/app/vmalert/notifier/config.go b/app/vmalert/notifier/config.go index d43cced4d..f7adf4147 100644 --- a/app/vmalert/notifier/config.go +++ b/app/vmalert/notifier/config.go @@ -63,8 +63,9 @@ type Config struct { } // StaticConfig contains list of static targets in the following form: -// targets: -// [ - '' ] +// +// targets: +// [ - '' ] type StaticConfig struct { Targets []string `yaml:"targets"` } diff --git a/app/vmalert/notifier/init.go b/app/vmalert/notifier/init.go index a1b8bcac6..ad20f4d81 100644 --- a/app/vmalert/notifier/init.go +++ b/app/vmalert/notifier/init.go @@ -74,9 +74,10 @@ var ( // Init returns a function for retrieving actual list of Notifier objects. // Init works in two mods: -// * configuration via flags (for backward compatibility). Is always static +// - configuration via flags (for backward compatibility). Is always static // and don't support live reloads. -// * configuration via file. Supports live reloads and service discovery. +// - configuration via file. Supports live reloads and service discovery. +// // Init returns an error if both mods are used. func Init(gen AlertURLGenerator, extLabels map[string]string, extURL string) (func() []Notifier, error) { if externalLabels != nil || externalURL != "" { diff --git a/app/vmctl/vm/timeseries.go b/app/vmctl/vm/timeseries.go index 3c4580eff..188d56033 100644 --- a/app/vmctl/vm/timeseries.go +++ b/app/vmctl/vm/timeseries.go @@ -54,7 +54,7 @@ func (cw *cWriter) printf(format string, args ...interface{}) { cw.err = err } -//"{"metric":{"__name__":"cpu_usage_guest","arch":"x64","hostname":"host_19",},"timestamps":[1567296000000,1567296010000],"values":[1567296000000,66]} +// "{"metric":{"__name__":"cpu_usage_guest","arch":"x64","hostname":"host_19",},"timestamps":[1567296000000,1567296010000],"values":[1567296000000,66]} func (ts *TimeSeries) write(w io.Writer) (int, error) { timestamps := ts.Timestamps values := ts.Values diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index 41bc7636f..04fa2196f 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -1111,7 +1111,6 @@ func (cp *commonParams) IsDefaultTimeRange() bool { // - match[] // - extra_label // - extra_filters[] -// func getExportParams(r *http.Request, startTime time.Time) (*commonParams, error) { cp, err := getCommonParams(r, startTime, true) if err != nil { @@ -1129,7 +1128,6 @@ func getExportParams(r *http.Request, startTime time.Time) (*commonParams, error // - match[] // - extra_label // - extra_filters[] -// func getCommonParams(r *http.Request, startTime time.Time, requireNonEmptyMatch bool) (*commonParams, error) { deadline := searchutils.GetDeadlineForQuery(r, startTime) start, err := searchutils.GetTime(r, "start", 0) diff --git a/app/vmselect/searchutils/searchutils.go b/app/vmselect/searchutils/searchutils.go index 3e29fa041..a52fa553e 100644 --- a/app/vmselect/searchutils/searchutils.go +++ b/app/vmselect/searchutils/searchutils.go @@ -239,10 +239,13 @@ func (d *Deadline) String() string { // // Label filters can be present in extra_label and extra_filters[] query args. // They are combined. For example, the following query args: -// extra_label=t1=v1&extra_label=t2=v2&extra_filters[]={env="prod",team="devops"}&extra_filters={env=~"dev|staging",team!="devops"} +// +// extra_label=t1=v1&extra_label=t2=v2&extra_filters[]={env="prod",team="devops"}&extra_filters={env=~"dev|staging",team!="devops"} +// // should be translated to the following filters joined with "or": -// {env="prod",team="devops",t1="v1",t2="v2"} -// {env=~"dev|staging",team!="devops",t1="v1",t2="v2"} +// +// {env="prod",team="devops",t1="v1",t2="v2"} +// {env=~"dev|staging",team!="devops",t1="v1",t2="v2"} func GetExtraTagFilters(r *http.Request) ([][]storage.TagFilter, error) { var tagFilters []storage.TagFilter for _, match := range r.Form["extra_label"] { diff --git a/app/vmui/packages/vmui/web/main.go b/app/vmui/packages/vmui/web/main.go index cc268eedf..f3ae54c10 100644 --- a/app/vmui/packages/vmui/web/main.go +++ b/app/vmui/packages/vmui/web/main.go @@ -8,8 +8,9 @@ import ( ) // specific files -//go:embed favicon-32x32.png robots.txt index.html manifest.json asset-manifest.json // static content +// +//go:embed favicon-32x32.png robots.txt index.html manifest.json asset-manifest.json //go:embed static var files embed.FS diff --git a/lib/flagutil/array.go b/lib/flagutil/array.go index 23f8d945f..245301b50 100644 --- a/lib/flagutil/array.go +++ b/lib/flagutil/array.go @@ -51,13 +51,12 @@ func NewArrayInt(name string, description string) *ArrayInt { // // The following example sets equivalent flag array with two items (value1, value2): // -// -foo=value1 -foo=value2 -// -foo=value1,value2 +// -foo=value1 -foo=value2 +// -foo=value1,value2 // // Flag values may be quoted. For instance, the following arg creates an array of ("a", "b, c") items: // -// -foo='a,"b, c"' -// +// -foo='a,"b, c"' type Array []string // String implements flag.Value interface diff --git a/lib/leveledbytebufferpool/pool.go b/lib/leveledbytebufferpool/pool.go index 96ba6a2d1..736788a6a 100644 --- a/lib/leveledbytebufferpool/pool.go +++ b/lib/leveledbytebufferpool/pool.go @@ -9,11 +9,11 @@ import ( // pools contains pools for byte slices of various capacities. // -// pools[0] is for capacities from 0 to 8 -// pools[1] is for capacities from 9 to 16 -// pools[2] is for capacities from 17 to 32 -// ... -// pools[n] is for capacities from 2^(n+2)+1 to 2^(n+3) +// pools[0] is for capacities from 0 to 8 +// pools[1] is for capacities from 9 to 16 +// pools[2] is for capacities from 17 to 32 +// ... +// pools[n] is for capacities from 2^(n+2)+1 to 2^(n+3) // // Limit the maximum capacity to 2^18, since there are no performance benefits // in caching byte slices with bigger capacities. diff --git a/lib/metricsql/doc.go b/lib/metricsql/doc.go index 1c5bc4006..97f55ffae 100644 --- a/lib/metricsql/doc.go +++ b/lib/metricsql/doc.go @@ -1,3 +1,2 @@ // Package metricsql has been moved to https://github.com/VictoriaMetrics/metricsql . -// package metricsql diff --git a/lib/protoparser/csvimport/column_descriptor.go b/lib/protoparser/csvimport/column_descriptor.go index 3260e6ad0..3bdb96a7f 100644 --- a/lib/protoparser/csvimport/column_descriptor.go +++ b/lib/protoparser/csvimport/column_descriptor.go @@ -34,19 +34,19 @@ const maxColumnsPerRow = 64 * 1024 // // s must have comma-separated list of the following entries: // -// :: +// :: // // Where: // // - is numeric csv column position. The first column has position 1. // - is one of the following types: -// - time - the corresponding column contains timestamp. Timestamp format is determined by . The following formats are supported: -// - unix_s - unix timestamp in seconds -// - unix_ms - unix timestamp in milliseconds -// - unix_ns - unix_timestamp in nanoseconds -// - rfc3339 - RFC3339 format in the form `2006-01-02T15:04:05Z07:00` -// - label - the corresponding column contains metric label with the name set in . -// - metric - the corresponding column contains metric value with the name set in . +// - time - the corresponding column contains timestamp. Timestamp format is determined by . The following formats are supported: +// - - unix_s - unix timestamp in seconds +// - - unix_ms - unix timestamp in milliseconds +// - - unix_ns - unix_timestamp in nanoseconds +// - - rfc3339 - RFC3339 format in the form `2006-01-02T15:04:05Z07:00` +// - label - the corresponding column contains metric label with the name set in . +// - metric - the corresponding column contains metric value with the name set in . // // s must contain at least a single 'metric' column and no more than a single `time` column. func ParseColumnDescriptors(s string) ([]ColumnDescriptor, error) { diff --git a/lib/storage/partition_search.go b/lib/storage/partition_search.go index ace590284..cb9125cbf 100644 --- a/lib/storage/partition_search.go +++ b/lib/storage/partition_search.go @@ -58,7 +58,7 @@ func (pts *partitionSearch) reset() { // tsids must be sorted. // tsids cannot be modified after the Init call, since it is owned by pts. // -/// MustClose must be called when partition search is done. +// MustClose must be called when partition search is done. func (pts *partitionSearch) Init(pt *partition, tsids []TSID, tr TimeRange) { if pts.needClosing { logger.Panicf("BUG: missing partitionSearch.MustClose call before the next call to Init") diff --git a/lib/storage/tag_filters.go b/lib/storage/tag_filters.go index 4e6899504..1fda9ab11 100644 --- a/lib/storage/tag_filters.go +++ b/lib/storage/tag_filters.go @@ -581,16 +581,17 @@ func newMatchFuncForOrSuffixes(orValues []string) (reMatch func(b []byte) bool, } // getOptimizedReMatchFunc tries returning optimized function for matching the given expr. -// '.*' -// '.+' -// 'literal.*' -// 'literal.+' -// '.*literal' -// '.+literal -// '.*literal.*' -// '.*literal.+' -// '.+literal.*' -// '.+literal.+' +// +// '.*' +// '.+' +// 'literal.*' +// 'literal.+' +// '.*literal' +// '.+literal +// '.*literal.*' +// '.*literal.+' +// '.+literal.*' +// '.+literal.+' // // It returns reMatch if it cannot find optimized function. //