Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set version via -ldflags #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
"gopkg.in/alecthomas/kingpin.v2"
)

const version string = "0.4.7"
// Version is updated at compile-time via -ldflags.
var version string = "development"

var (
showVersion = kingpin.Flag("version", "Print version information").Default().Bool()
Expand Down Expand Up @@ -189,7 +190,7 @@ func refreshDNS(targets []*target, monitor *mon.Monitor) {
func startServer(monitor *mon.Monitor) {
log.Infof("Starting ping exporter (Version: %s)", version)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, indexHTML, *metricsPath)
fmt.Fprintf(w, indexHTML, version, *metricsPath)
})

reg := prometheus.NewRegistry()
Expand Down Expand Up @@ -273,7 +274,7 @@ const indexHTML = `<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>ping Exporter (Version ` + version + `)</title>
<title>ping Exporter (Version %s)</title>
</head>
<body>
<h1>ping Exporter</h1>
Expand Down