When I run a simple prometheues hello world in go
<code> package main
import (
"log"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
requests = promauto.NewCounter(
prometheus.CounterOpts{
Name: "hello_worlds_total",
Help: "Hello Worlds requested.",
})
)
func handler(w http.ResponseWriter, r *http.Request) {
requests.Inc()
w.Write([]byte("Hello World"))
}
func main() {
http.HandleFunc("/", handler)
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8000", nil))
}
</code>
<code> package main
import (
"log"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
requests = promauto.NewCounter(
prometheus.CounterOpts{
Name: "hello_worlds_total",
Help: "Hello Worlds requested.",
})
)
func handler(w http.ResponseWriter, r *http.Request) {
requests.Inc()
w.Write([]byte("Hello World"))
}
func main() {
http.HandleFunc("/", handler)
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8000", nil))
}
</code>
package main
import (
"log"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
requests = promauto.NewCounter(
prometheus.CounterOpts{
Name: "hello_worlds_total",
Help: "Hello Worlds requested.",
})
)
func handler(w http.ResponseWriter, r *http.Request) {
requests.Inc()
w.Write([]byte("Hello World"))
}
func main() {
http.HandleFunc("/", handler)
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8000", nil))
}
I’ve got a message:
<code> /root/go/pkg/mod/github.com/prometheus/[email protected]/model/metric.go:367:33: undefined: strings.CutPrefix
note: module requires Go 1.20
# github.com/klauspost/compress/zstd
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:510:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:521:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:522:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:523:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
note: module requires Go 1.20
</code>
<code> /root/go/pkg/mod/github.com/prometheus/[email protected]/model/metric.go:367:33: undefined: strings.CutPrefix
note: module requires Go 1.20
# github.com/klauspost/compress/zstd
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:510:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:521:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:522:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:523:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
note: module requires Go 1.20
</code>
/root/go/pkg/mod/github.com/prometheus/[email protected]/model/metric.go:367:33: undefined: strings.CutPrefix
note: module requires Go 1.20
# github.com/klauspost/compress/zstd
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:510:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:521:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:522:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
/root/go/pkg/mod/github.com/klauspost/[email protected]/zstd/dict.go:523:32: binary.LittleEndian.AppendUint32 undefined (type binary.littleEndian has no field or method AppendUint32)
note: module requires Go 1.20
What does this mean?
1