diff --git a/.golangci.yaml b/.golangci.yaml index 72bab980..982c98bb 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -29,11 +29,9 @@ linters: - gocritic # We should strive to enable these: - - testpackage - stylecheck - wrapcheck - goerr113 - - errorlint - forcetypeassert - errname - gosec @@ -46,6 +44,7 @@ linters: - cyclop - nestif - wsl # might be incompatible with gofumpt + - testpackage linters-settings: varnamelen: diff --git a/cmd/headscale/cli/utils.go b/cmd/headscale/cli/utils.go index ad49c013..f60a72c5 100644 --- a/cmd/headscale/cli/utils.go +++ b/cmd/headscale/cli/utils.go @@ -53,7 +53,7 @@ func LoadConfig(path string) error { viper.SetDefault("cli.timeout", "5s") if err := viper.ReadInConfig(); err != nil { - return fmt.Errorf("Fatal error reading config file: %s \n", err) + return fmt.Errorf("Fatal error reading config file: %w", err) } // Collect any validation errors and return them all at once diff --git a/machine.go b/machine.go index 4dc9cd99..b0c003fd 100644 --- a/machine.go +++ b/machine.go @@ -284,7 +284,7 @@ func (h *Headscale) UpdateMachine(machine *Machine) error { // DeleteMachine softs deletes a Machine from the database. func (h *Headscale) DeleteMachine(machine *Machine) error { err := h.RemoveSharedMachineFromAllNamespaces(machine) - if err != nil && err != errorMachineNotShared { + if err != nil && errors.Is(err, errorMachineNotShared) { return err } @@ -301,7 +301,7 @@ func (h *Headscale) DeleteMachine(machine *Machine) error { // HardDeleteMachine hard deletes a Machine from the database. func (h *Headscale) HardDeleteMachine(machine *Machine) error { err := h.RemoveSharedMachineFromAllNamespaces(machine) - if err != nil && err != errorMachineNotShared { + if err != nil && errors.Is(err, errorMachineNotShared) { return err } diff --git a/utils.go b/utils.go index 803cfc5d..e291703a 100644 --- a/utils.go +++ b/utils.go @@ -46,7 +46,7 @@ func decodeMsg( } // fmt.Println(string(decrypted)) if err := json.Unmarshal(decrypted, output); err != nil { - return fmt.Errorf("response: %v", err) + return fmt.Errorf("response: %w", err) } return nil