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/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..31274fb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: +- repo: https://github.com/dnephin/pre-commit-golang + rev: v0.5.1 + hooks: + - id: go-fmt + - id: go-vet + - id: validate-toml + - id: no-go-testing + - id: go-unit-tests + - id: go-build + - 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 diff --git a/config/configuration.go b/config/configuration.go index 32131bf..967ef03 100644 --- a/config/configuration.go +++ b/config/configuration.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "reflect" + "runtime" "strings" "time" @@ -90,7 +91,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) @@ -176,12 +177,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" } @@ -191,6 +192,7 @@ func (c EnvConfig) show() { log.Info("------------------------------------") log.Info("- PI-Hole exporter configuration -") log.Info("------------------------------------") + log.Info("Go version: ", runtime.Version()) for i := 0; i < val.NumField(); i++ { valueField := val.Field(i) typeField := val.Type().Field(i)