Indent example in godoc consistently (#1226)

* Indent example in godoc consistently

Signed-off-by: Jon Kartago Lamida <me@lamida.net>

* Add missed one line indentation fix

Signed-off-by: Jon Kartago Lamida <me@lamida.net>

---------

Signed-off-by: Jon Kartago Lamida <me@lamida.net>
This commit is contained in:
Jon Kartago Lamida 2023-03-02 00:45:01 +08:00 committed by GitHub
parent ffbbe800f2
commit 3d2cf0b338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 36 deletions

View File

@ -37,35 +37,35 @@
// //
// type metrics struct { // type metrics struct {
// cpuTemp prometheus.Gauge // cpuTemp prometheus.Gauge
// hdFailures *prometheus.CounterVec // hdFailures *prometheus.CounterVec
// } // }
// //
// func NewMetrics(reg prometheus.Registerer) *metrics { // func NewMetrics(reg prometheus.Registerer) *metrics {
// m := &metrics{ // m := &metrics{
// cpuTemp: prometheus.NewGauge(prometheus.GaugeOpts{ // cpuTemp: prometheus.NewGauge(prometheus.GaugeOpts{
// Name: "cpu_temperature_celsius", // Name: "cpu_temperature_celsius",
// Help: "Current temperature of the CPU.", // Help: "Current temperature of the CPU.",
// }), // }),
// hdFailures: prometheus.NewCounterVec( // hdFailures: prometheus.NewCounterVec(
// prometheus.CounterOpts{ // prometheus.CounterOpts{
// Name: "hd_errors_total", // Name: "hd_errors_total",
// Help: "Number of hard-disk errors.", // Help: "Number of hard-disk errors.",
// }, // },
// []string{"device"}, // []string{"device"},
// ), // ),
// } // }
// reg.MustRegister(m.cpuTemp) // reg.MustRegister(m.cpuTemp)
// reg.MustRegister(m.hdFailures) // reg.MustRegister(m.hdFailures)
// return m // return m
// } // }
// //
// func main() { // func main() {
// // Create a non-global registry. // // Create a non-global registry.
// reg := prometheus.NewRegistry() // reg := prometheus.NewRegistry()
// //
// // Create new metrics and register them using the custom registry. // // Create new metrics and register them using the custom registry.
// m := NewMetrics(reg) // m := NewMetrics(reg)
// // Set values for the new created metrics. // // Set values for the new created metrics.
// m.cpuTemp.Set(65.3) // m.cpuTemp.Set(65.3)
// m.hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc() // m.hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc()
// //

View File

@ -28,30 +28,30 @@
// package main // package main
// //
// import ( // import (
// "math/rand" // "math/rand"
// "net/http" // "net/http"
// //
// "github.com/prometheus/client_golang/prometheus" // "github.com/prometheus/client_golang/prometheus"
// "github.com/prometheus/client_golang/prometheus/promauto" // "github.com/prometheus/client_golang/prometheus/promauto"
// "github.com/prometheus/client_golang/prometheus/promhttp" // "github.com/prometheus/client_golang/prometheus/promhttp"
// ) // )
// //
// var histogram = promauto.NewHistogram(prometheus.HistogramOpts{ // var histogram = promauto.NewHistogram(prometheus.HistogramOpts{
// Name: "random_numbers", // Name: "random_numbers",
// Help: "A histogram of normally distributed random numbers.", // Help: "A histogram of normally distributed random numbers.",
// Buckets: prometheus.LinearBuckets(-3, .1, 61), // Buckets: prometheus.LinearBuckets(-3, .1, 61),
// }) // })
// //
// func Random() { // func Random() {
// for { // for {
// histogram.Observe(rand.NormFloat64()) // histogram.Observe(rand.NormFloat64())
// } // }
// } // }
// //
// func main() { // func main() {
// go Random() // go Random()
// http.Handle("/metrics", promhttp.Handler()) // http.Handle("/metrics", promhttp.Handler())
// http.ListenAndServe(":1971", nil) // http.ListenAndServe(":1971", nil)
// } // }
// //
// Prometheus's version of a minimal hello-world program: // Prometheus's version of a minimal hello-world program: