Files
MarioandGitHub e0354d1bed Update Prometheus to v0.307.2, OTel collector contrib to v0.138.0, OTel to v1.44.0 (#5810)
* Update Prometheus to v0.307.2

* Update otel collector

* Update OTel collector
2025-10-28 11:30:17 +01:00

37 lines
571 B
Go

package file
import "strings"
type Source struct {
raw string
}
func NewSource(contents string) Source {
return Source{
raw: contents,
}
}
func (s Source) String() string {
return s.raw
}
func (s Source) Snippet(line int) (string, bool) {
if s.raw == "" {
return "", false
}
var start int
for i := 1; i < line; i++ {
pos := strings.IndexByte(s.raw[start:], '\n')
if pos < 0 {
return "", false
}
start += pos + 1
}
end := start + strings.IndexByte(s.raw[start:], '\n')
if end < start {
end = len(s.raw)
}
return s.raw[start:end], true
}