From 796072a5a44d81c388a794b264078ef0b1486c48 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 14 Nov 2021 18:09:22 +0100 Subject: [PATCH] Add and fix ifshort --- .golangci.yaml | 1 - cmd/headscale/cli/utils.go | 3 +-- cmd/headscale/headscale.go | 3 +-- db.go | 3 +-- machine.go | 3 +-- oidc.go | 3 +-- 6 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index b97922b1..8edc1b5a 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -29,7 +29,6 @@ linters: - testpackage - stylecheck - wrapcheck - - ifshort - gomnd - goerr113 - errorlint diff --git a/cmd/headscale/cli/utils.go b/cmd/headscale/cli/utils.go index 80bded8a..343ebe30 100644 --- a/cmd/headscale/cli/utils.go +++ b/cmd/headscale/cli/utils.go @@ -52,8 +52,7 @@ func LoadConfig(path string) error { viper.SetDefault("cli.insecure", false) viper.SetDefault("cli.timeout", "5s") - err := viper.ReadInConfig() - if err != nil { + if err := viper.ReadInConfig(); err != nil { return fmt.Errorf("Fatal error reading config file: %s \n", err) } diff --git a/cmd/headscale/headscale.go b/cmd/headscale/headscale.go index c6ac0043..f3352474 100644 --- a/cmd/headscale/headscale.go +++ b/cmd/headscale/headscale.go @@ -43,8 +43,7 @@ func main() { NoColor: !colors, }) - err := cli.LoadConfig("") - if err != nil { + if err := cli.LoadConfig(""); err != nil { log.Fatal().Err(err) } diff --git a/db.go b/db.go index da81e301..77d4ba03 100644 --- a/db.go +++ b/db.go @@ -105,8 +105,7 @@ func (h *Headscale) setValue(key string, value string) error { Value: value, } - _, err := h.getValue(key) - if err == nil { + if _, err := h.getValue(key); err == nil { h.db.Model(&kv).Where("key = ?", key).Update("value", value) return nil diff --git a/machine.go b/machine.go index e0fe2a3e..6443c828 100644 --- a/machine.go +++ b/machine.go @@ -331,8 +331,7 @@ func (m *Machine) GetHostInfo() (*tailcfg.Hostinfo, error) { } func (h *Headscale) isOutdated(m *Machine) bool { - err := h.UpdateMachine(m) - if err != nil { + if err := h.UpdateMachine(m); err != nil { // It does not seem meaningful to propagate this error as the end result // will have to be that the machine has to be considered outdated. return true diff --git a/oidc.go b/oidc.go index 63a1abe0..234a0bf3 100644 --- a/oidc.go +++ b/oidc.go @@ -68,8 +68,7 @@ func (h *Headscale) RegisterOIDC(c *gin.Context) { } b := make([]byte, 16) - _, err := rand.Read(b) - if err != nil { + if _, err := rand.Read(b); err != nil { log.Error().Msg("could not read 16 bytes from rand") c.String(http.StatusInternalServerError, "could not read 16 bytes from rand")