Fix linter errors

Mostly comment issues and unused variables.

Signed-off-by: Lukasz Mierzwa <l.mierzwa@gmail.com>
This commit is contained in:
Lukasz Mierzwa 2025-04-15 18:02:34 +01:00
parent bb76966992
commit 05088aaa12

View File

@ -76,7 +76,7 @@ func (ls Labels) IsZero() bool {
// MatchLabels returns a subset of Labels that matches/does not match with the provided label names based on the 'on' boolean. // MatchLabels returns a subset of Labels that matches/does not match with the provided label names based on the 'on' boolean.
// If on is set to true, it returns the subset of labels that match with the provided label names and its inverse when 'on' is set to false. // If on is set to true, it returns the subset of labels that match with the provided label names and its inverse when 'on' is set to false.
// TODO: This is only used in printing an error message // TODO: This is only used in printing an error message.
func (ls Labels) MatchLabels(on bool, names ...string) Labels { func (ls Labels) MatchLabels(on bool, names ...string) Labels {
b := NewBuilder(ls) b := NewBuilder(ls)
if on { if on {
@ -298,6 +298,7 @@ func Equal(ls, o Labels) bool {
func EmptyLabels() Labels { func EmptyLabels() Labels {
return Labels{} return Labels{}
} }
func yoloBytes(s string) []byte { func yoloBytes(s string) []byte {
return unsafe.Slice(unsafe.StringData(s), len(s)) return unsafe.Slice(unsafe.StringData(s), len(s))
} }
@ -370,7 +371,7 @@ func Compare(a, b Labels) int {
return +1 return +1
} }
// Copy labels from b on top of whatever was in ls previously, reusing memory or expanding if needed. // CopyFrom will copy labels from b on top of whatever was in ls previously, reusing memory or expanding if needed.
func (ls *Labels) CopyFrom(b Labels) { func (ls *Labels) CopyFrom(b Labels) {
ls.data = b.data // strings are immutable ls.data = b.data // strings are immutable
} }
@ -440,11 +441,11 @@ func (ls Labels) DropMetricName() Labels {
} }
// InternStrings is a no-op because it would only save when the whole set of labels is identical. // InternStrings is a no-op because it would only save when the whole set of labels is identical.
func (ls *Labels) InternStrings(intern func(string) string) { func (ls *Labels) InternStrings(_ func(string) string) {
} }
// ReleaseStrings is a no-op for the same reason as InternStrings. // ReleaseStrings is a no-op for the same reason as InternStrings.
func (ls Labels) ReleaseStrings(release func(string)) { func (ls Labels) ReleaseStrings(_ func(string)) {
} }
// Builder allows modifying Labels. // Builder allows modifying Labels.
@ -561,7 +562,7 @@ func encodeVarint(data []byte, offset int, v uint64) int {
return base return base
} }
// Special code for the common case that a size is less than 128 // Special code for the common case that a size is less than 128.
func encodeSize(data []byte, offset, v int) int { func encodeSize(data []byte, offset, v int) int {
if v < 1<<7 { if v < 1<<7 {
offset-- offset--
@ -630,7 +631,7 @@ func (b *ScratchBuilder) Add(name, value string) {
b.add = append(b.add, Label{Name: name, Value: value}) b.add = append(b.add, Label{Name: name, Value: value})
} }
// Add a name/value pair, using []byte instead of string to reduce memory allocations. // UnsafeAddBytes adds a name/value pair using []byte instead of string to reduce memory allocations.
// The values must remain live until Labels() is called. // The values must remain live until Labels() is called.
func (b *ScratchBuilder) UnsafeAddBytes(name, value []byte) { func (b *ScratchBuilder) UnsafeAddBytes(name, value []byte) {
b.add = append(b.add, Label{Name: yoloString(name), Value: yoloString(value)}) b.add = append(b.add, Label{Name: yoloString(name), Value: yoloString(value)})
@ -658,7 +659,7 @@ func (b *ScratchBuilder) Labels() Labels {
return b.output return b.output
} }
// Write the newly-built Labels out to ls, reusing an internal buffer. // Overwrite will write the newly-built Labels out to ls, reusing an internal buffer.
// Callers must ensure that there are no other references to ls, or any strings fetched from it. // Callers must ensure that there are no other references to ls, or any strings fetched from it.
func (b *ScratchBuilder) Overwrite(ls *Labels) { func (b *ScratchBuilder) Overwrite(ls *Labels) {
size := labelsSize(b.add) size := labelsSize(b.add)
@ -671,7 +672,7 @@ func (b *ScratchBuilder) Overwrite(ls *Labels) {
ls.data = yoloString(b.overwriteBuffer) ls.data = yoloString(b.overwriteBuffer)
} }
// Symbol-table is no-op, just for api parity with dedupelabels. // SymbolTable is no-op, just for api parity with dedupelabels.
type SymbolTable struct{} type SymbolTable struct{}
func NewSymbolTable() *SymbolTable { return nil } func NewSymbolTable() *SymbolTable { return nil }