Add and fix errorlint

This commit is contained in:
Kristoffer Dalby 2021-11-15 16:26:41 +00:00
parent 2dde1242cf
commit 0c45f8d252
No known key found for this signature in database
GPG key ID: 09F62DC067465735
4 changed files with 5 additions and 6 deletions

View file

@ -29,11 +29,9 @@ linters:
- gocritic - gocritic
# We should strive to enable these: # We should strive to enable these:
- testpackage
- stylecheck - stylecheck
- wrapcheck - wrapcheck
- goerr113 - goerr113
- errorlint
- forcetypeassert - forcetypeassert
- errname - errname
- gosec - gosec
@ -46,6 +44,7 @@ linters:
- cyclop - cyclop
- nestif - nestif
- wsl # might be incompatible with gofumpt - wsl # might be incompatible with gofumpt
- testpackage
linters-settings: linters-settings:
varnamelen: varnamelen:

View file

@ -53,7 +53,7 @@ func LoadConfig(path string) error {
viper.SetDefault("cli.timeout", "5s") viper.SetDefault("cli.timeout", "5s")
if err := viper.ReadInConfig(); err != nil { 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 // Collect any validation errors and return them all at once

View file

@ -284,7 +284,7 @@ func (h *Headscale) UpdateMachine(machine *Machine) error {
// DeleteMachine softs deletes a Machine from the database. // DeleteMachine softs deletes a Machine from the database.
func (h *Headscale) DeleteMachine(machine *Machine) error { func (h *Headscale) DeleteMachine(machine *Machine) error {
err := h.RemoveSharedMachineFromAllNamespaces(machine) err := h.RemoveSharedMachineFromAllNamespaces(machine)
if err != nil && err != errorMachineNotShared { if err != nil && errors.Is(err, errorMachineNotShared) {
return err return err
} }
@ -301,7 +301,7 @@ func (h *Headscale) DeleteMachine(machine *Machine) error {
// HardDeleteMachine hard deletes a Machine from the database. // HardDeleteMachine hard deletes a Machine from the database.
func (h *Headscale) HardDeleteMachine(machine *Machine) error { func (h *Headscale) HardDeleteMachine(machine *Machine) error {
err := h.RemoveSharedMachineFromAllNamespaces(machine) err := h.RemoveSharedMachineFromAllNamespaces(machine)
if err != nil && err != errorMachineNotShared { if err != nil && errors.Is(err, errorMachineNotShared) {
return err return err
} }

View file

@ -46,7 +46,7 @@ func decodeMsg(
} }
// fmt.Println(string(decrypted)) // fmt.Println(string(decrypted))
if err := json.Unmarshal(decrypted, output); err != nil { if err := json.Unmarshal(decrypted, output); err != nil {
return fmt.Errorf("response: %v", err) return fmt.Errorf("response: %w", err)
} }
return nil return nil