mirror of
https://github.com/prometheus/prometheus
synced 2024-12-23 15:04:13 +00:00
Fix golint issues.
Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
parent
51057daaa4
commit
269e7c8091
@ -334,7 +334,7 @@ func main() {
|
||||
level.Info(logger).Log("build_context", version.BuildContext())
|
||||
level.Info(logger).Log("host_details", prom_runtime.Uname())
|
||||
level.Info(logger).Log("fd_limits", prom_runtime.FdLimits())
|
||||
level.Info(logger).Log("vm_limits", prom_runtime.VmLimits())
|
||||
level.Info(logger).Log("vm_limits", prom_runtime.VMLimits())
|
||||
|
||||
var (
|
||||
localStorage = &readyStorage{}
|
||||
|
@ -301,16 +301,14 @@ func Compare(a, b Labels) int {
|
||||
if a[i].Name != b[i].Name {
|
||||
if a[i].Name < b[i].Name {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
return 1
|
||||
}
|
||||
if a[i].Value != b[i].Value {
|
||||
if a[i].Value < b[i].Value {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
return 1
|
||||
}
|
||||
}
|
||||
// If all labels so far were in common, the set with fewer labels comes first.
|
||||
|
@ -20,7 +20,7 @@ func FdLimits() string {
|
||||
return "N/A"
|
||||
}
|
||||
|
||||
// VmLimits not supported on Windows
|
||||
func VmLimits() string {
|
||||
// VMLimits not supported on Windows
|
||||
func VMLimits() string {
|
||||
return "N/A"
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// VmLimits returns the soft and hard limits for virtual memory.
|
||||
func VmLimits() string {
|
||||
// VMLimits returns the soft and hard limits for virtual memory.
|
||||
func VMLimits() string {
|
||||
return getLimits(syscall.RLIMIT_AS, "b")
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// VmLimits returns the soft and hard limits for virtual memory.
|
||||
func VmLimits() string {
|
||||
// VMLimits returns the soft and hard limits for virtual memory.
|
||||
func VMLimits() string {
|
||||
return getLimits(syscall.RLIMIT_DATA, "b")
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ S [ ]
|
||||
<sComment>HELP{S} l.state = sMeta1; return tHelp
|
||||
<sComment>TYPE{S} l.state = sMeta1; return tType
|
||||
<sComment>UNIT{S} l.state = sMeta1; return tUnit
|
||||
<sComment>"EOF"\n? l.state = sInit; return tEofWord
|
||||
<sComment>"EOF"\n? l.state = sInit; return tEOFWord
|
||||
<sMeta1>{M}({M}|{D})* l.state = sMeta2; return tMName
|
||||
<sMeta2>{S}{C}*\n l.state = sInit; return tText
|
||||
|
||||
|
@ -635,7 +635,7 @@ yyrule4: // UNIT{S}
|
||||
yyrule5: // "EOF"\n?
|
||||
{
|
||||
l.state = sInit
|
||||
return tEofWord
|
||||
return tEOFWord
|
||||
goto yystate0
|
||||
}
|
||||
yyrule6: // {M}({M}|{D})*
|
||||
|
@ -233,7 +233,7 @@ func (p *OpenMetricsParser) Next() (Entry, error) {
|
||||
p.hasExemplarTs = false
|
||||
|
||||
switch t := p.nextToken(); t {
|
||||
case tEofWord:
|
||||
case tEOFWord:
|
||||
if t := p.nextToken(); t != tEOF {
|
||||
return EntryInvalid, errors.New("unexpected data after # EOF")
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ const (
|
||||
tHelp
|
||||
tType
|
||||
tUnit
|
||||
tEofWord
|
||||
tEOFWord
|
||||
tText
|
||||
tComment
|
||||
tBlank
|
||||
@ -82,7 +82,7 @@ func (t token) String() string {
|
||||
return "TYPE"
|
||||
case tUnit:
|
||||
return "UNIT"
|
||||
case tEofWord:
|
||||
case tEOFWord:
|
||||
return "EOFWORD"
|
||||
case tText:
|
||||
return "TEXT"
|
||||
|
@ -870,7 +870,7 @@ func funcYear(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper)
|
||||
})
|
||||
}
|
||||
|
||||
// Functions is a list of all functions supported by PromQL, including their types.
|
||||
// FunctionCalls is a list of all functions supported by PromQL, including their types.
|
||||
var FunctionCalls = map[string]FunctionCall{
|
||||
"abs": funcAbs,
|
||||
"absent": funcAbsent,
|
||||
|
@ -399,9 +399,8 @@ func (e Expressions) PositionRange() PositionRange {
|
||||
Start: -1,
|
||||
End: -1,
|
||||
}
|
||||
} else {
|
||||
return mergeRanges(e[0], e[len(e)-1])
|
||||
}
|
||||
return mergeRanges(e[0], e[len(e)-1])
|
||||
}
|
||||
func (e *MatrixSelector) PositionRange() PositionRange {
|
||||
return PositionRange{
|
||||
|
@ -122,7 +122,7 @@ var key = map[string]ItemType{
|
||||
"bool": BOOL,
|
||||
}
|
||||
|
||||
// These are the default string representations for common Items. It does not
|
||||
// ItemTypeStr is the default string representations for common Items. It does not
|
||||
// imply that those are the only character sequences that can be lexed to such an Item.
|
||||
var ItemTypeStr = map[ItemType]string{
|
||||
LEFT_PAREN: "(",
|
||||
|
@ -94,12 +94,11 @@ type ParseErrors []ParseErr
|
||||
func (errs ParseErrors) Error() string {
|
||||
if len(errs) != 0 {
|
||||
return errs[0].Error()
|
||||
} else {
|
||||
// Should never happen
|
||||
// Panicking while printing an error seems like a bad idea, so the
|
||||
// situation is explained in the error message instead.
|
||||
return "error contains no error message"
|
||||
}
|
||||
// Should never happen
|
||||
// Panicking while printing an error seems like a bad idea, so the
|
||||
// situation is explained in the error message instead.
|
||||
return "error contains no error message"
|
||||
}
|
||||
|
||||
// ParseExpr returns the expression parsed from the input.
|
||||
@ -295,14 +294,13 @@ func (p *parser) Lex(lval *yySymType) int {
|
||||
if p.injecting {
|
||||
p.injecting = false
|
||||
return int(p.inject)
|
||||
} else {
|
||||
// Skip comments.
|
||||
for {
|
||||
p.lex.NextItem(&lval.item)
|
||||
typ = lval.item.Typ
|
||||
if typ != COMMENT {
|
||||
break
|
||||
}
|
||||
}
|
||||
// Skip comments.
|
||||
for {
|
||||
p.lex.NextItem(&lval.item)
|
||||
typ = lval.item.Typ
|
||||
if typ != COMMENT {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ func (node *Call) String() string {
|
||||
|
||||
func (node *MatrixSelector) String() string {
|
||||
// Copy the Vector selector before changing the offset
|
||||
var vecSelector VectorSelector = *node.VectorSelector.(*VectorSelector)
|
||||
vecSelector := *node.VectorSelector.(*VectorSelector)
|
||||
offset := ""
|
||||
if vecSelector.Offset != time.Duration(0) {
|
||||
offset = fmt.Sprintf(" offset %s", model.Duration(vecSelector.Offset))
|
||||
|
@ -39,6 +39,7 @@ import (
|
||||
"github.com/prometheus/prometheus/tsdb/chunkenc"
|
||||
tsdb_errors "github.com/prometheus/prometheus/tsdb/errors"
|
||||
"github.com/prometheus/prometheus/tsdb/fileutil"
|
||||
// Load the package into main to make sure minium Go version is met.
|
||||
_ "github.com/prometheus/prometheus/tsdb/goversion"
|
||||
"github.com/prometheus/prometheus/tsdb/wal"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
@ -234,7 +234,7 @@ func createIdxChkReaders(t *testing.T, tc []seriesSamples) (IndexReader, ChunkRe
|
||||
app.Append(smpl.t, smpl.v)
|
||||
}
|
||||
chkReader[chunkRef] = chunk
|
||||
chunkRef += 1
|
||||
chunkRef++
|
||||
}
|
||||
|
||||
ls := labels.FromMap(s.lset)
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"github.com/prometheus/prometheus/pkg/labels"
|
||||
)
|
||||
|
||||
var InvalidTimesError = fmt.Errorf("max time is lesser than min time")
|
||||
var ErrInvalidTimes = fmt.Errorf("max time is lesser than min time")
|
||||
|
||||
type MetricSample struct {
|
||||
TimestampMs int64
|
||||
@ -58,7 +58,7 @@ func CreateBlock(samples []*MetricSample, dir string, mint, maxt int64, logger l
|
||||
chunkRange = DefaultBlockDuration
|
||||
}
|
||||
if chunkRange < 0 {
|
||||
return "", InvalidTimesError
|
||||
return "", ErrInvalidTimes
|
||||
}
|
||||
head, err := CreateHead(samples, chunkRange, logger)
|
||||
if err != nil {
|
||||
|
@ -837,6 +837,7 @@ type segmentBufReader struct {
|
||||
off int // Offset of read data into current segment.
|
||||
}
|
||||
|
||||
// nolint:golint // TODO: Consider exporting segmentBufReader
|
||||
func NewSegmentBufReader(segs ...*Segment) *segmentBufReader {
|
||||
return &segmentBufReader{
|
||||
buf: bufio.NewReaderSize(segs[0], 16*pageSize),
|
||||
|
@ -11,7 +11,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package api_v2
|
||||
package apiv2
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
// Assets contains the project's assets.
|
||||
var Assets http.FileSystem = func() http.FileSystem {
|
||||
var Assets = func() http.FileSystem {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
Loading…
Reference in New Issue
Block a user