From 55dca92b790ab0c9756006c3a078307cf04a0fcf Mon Sep 17 00:00:00 2001 From: Galorhallen Date: Tue, 25 Oct 2022 09:43:34 +0200 Subject: [PATCH 1/2] Print go version at startup --- .gitignore | 1 + config/configuration.go | 8 +++++--- go.mod | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 20caf56..27ec8c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ vendor bin tmp + .vscode report.xml debug diff --git a/config/configuration.go b/config/configuration.go index 4fe187e..c8763ab 100644 --- a/config/configuration.go +++ b/config/configuration.go @@ -6,6 +6,7 @@ import ( "fmt" "log" "reflect" + "runtime" "strings" "time" @@ -89,7 +90,7 @@ func (c *Config) String() string { return fmt.Sprintf("", &c, strings.Join(buffer, ", ")) } -//Validate check if the config is valid +// Validate check if the config is valid func (c Config) Validate() error { if c.PIHoleProtocol != "http" && c.PIHoleProtocol != "https" { return fmt.Errorf("protocol %s is invalid. Must be http or https", c.PIHoleProtocol) @@ -175,12 +176,12 @@ func (c Config) hostnameURL() string { return s } -//PIHoleStatsURL returns the stats url +// PIHoleStatsURL returns the stats url func (c Config) PIHoleStatsURL() string { return c.hostnameURL() + "/admin/api.php?summaryRaw&overTimeData&topItems&recentItems&getQueryTypes&getForwardDestinations&getQuerySources&jsonForceObject" } -//PIHoleLoginURL returns the login url +// PIHoleLoginURL returns the login url func (c Config) PIHoleLoginURL() string { return c.hostnameURL() + "/admin/index.php?login" } @@ -190,6 +191,7 @@ func (c EnvConfig) show() { log.Println("------------------------------------") log.Println("- PI-Hole exporter configuration -") log.Println("------------------------------------") + log.Printf("Go version: %s", runtime.Version()) for i := 0; i < val.NumField(); i++ { valueField := val.Field(i) typeField := val.Type().Field(i) diff --git a/go.mod b/go.mod index d1e5fa2..fe9fc69 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/eko/pihole-exporter -go 1.17 +go 1.19 require ( github.com/heetch/confita v0.10.0 From fabf06d2729cddc47a0e50d69a319d2460f952cd Mon Sep 17 00:00:00 2001 From: Galorhallen Date: Tue, 25 Oct 2022 10:00:54 +0200 Subject: [PATCH 2/2] Add pre-commit --- .pre-commit-config.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8399d90..31274fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,4 +8,11 @@ repos: - id: no-go-testing - id: go-unit-tests - id: go-build - - id: go-mod-tidy \ No newline at end of file + - id: go-mod-tidy +- repo: https://github.com/pre-commit/pre-commit-hooks.git + rev: v4.3.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + - id: mixed-line-ending + - id: check-merge-conflict