Skip to content

Commit

Permalink
minor linter cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronhurt committed Apr 19, 2024
1 parent 6d2ba5a commit c482abb
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Summary

IPman is a simple tool to automatically update DNS records (A and AAAA) based on the external local IPv4 and/or IPv6
address of the local machine. Currently it uses ipify.com for the external address lookup and supports writing
address of the local machine. It uses ipify.com for the external address lookup and supports writing
records to GoDaddy's DNS API. Both backend providers are modeled as interfaces to allow adding additional backends as
needed in the future.

Expand Down
4 changes: 2 additions & 2 deletions command/check/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func (c *Command) Run(args []string) int {

// init flags
if err = c.setupFlags(args); err != nil {
c.Log.Printf("[Error] Failed to init flags: %s", err.Error())
c.Log.Printf("[Error] Failed to init flags: %w", err)

Check failure on line 32 in command/check/command.go

View workflow job for this annotation

GitHub Actions / run checks

printf: (*log.Logger).Printf does not support error-wrapping directive %w (govet)
return 1
}

// check ip
if err = c.checkIP(); err != nil {
c.Log.Printf("[Error] Failed to check addresses: %s", err.Error())
c.Log.Printf("[Error] Failed to check addresses: %w", err)

Check failure on line 38 in command/check/command.go

View workflow job for this annotation

GitHub Actions / run checks

printf: (*log.Logger).Printf does not support error-wrapping directive %w (govet)
return 1
}

Expand Down
2 changes: 1 addition & 1 deletion command/check/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (c *Command) setupFlags(args []string) error {

// init flagset
cmdFlags = flag.NewFlagSet("check", flag.ContinueOnError)
cmdFlags.Usage = func() { fmt.Fprint(os.Stdout, c.Help()); os.Exit(0) }
cmdFlags.Usage = func() { _, _ = fmt.Fprint(os.Stdout, c.Help()); os.Exit(0) }

// declare flags
cmdFlags.BoolVar(&c.config.v4, "4", false,
Expand Down
5 changes: 2 additions & 3 deletions command/update/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ func (c *Command) Run(args []string) int {

// init flags
if err = c.setupFlags(args); err != nil {
c.Log.Printf("[Error] Failed to init flags: %s", err.Error())
c.Log.Printf("[Error] Failed to init flags: %w", err)

Check failure on line 40 in command/update/command.go

View workflow job for this annotation

GitHub Actions / run checks

printf: (*log.Logger).Printf does not support error-wrapping directive %w (govet)
return 1
}

// attempt to update p
if err = c.updateIP(); err != nil {
c.Log.Printf("[Error] Failed to update dns record: %s",
err.Error())
c.Log.Printf("[Error] Failed to update dns record: %w", err)

Check failure on line 46 in command/update/command.go

View workflow job for this annotation

GitHub Actions / run checks

printf: (*log.Logger).Printf does not support error-wrapping directive %w (govet)
return 1
}

Expand Down
2 changes: 1 addition & 1 deletion command/update/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (c *Command) setupFlags(args []string) error {

// init flagset
cmdFlags = flag.NewFlagSet("update", flag.ContinueOnError)
cmdFlags.Usage = func() { fmt.Fprint(os.Stdout, c.Help()); os.Exit(0) }
cmdFlags.Usage = func() { _, _ = fmt.Fprint(os.Stdout, c.Help()); os.Exit(0) }

// declare flags
cmdFlags.BoolVar(&c.config.v4, "4", false,
Expand Down
2 changes: 1 addition & 1 deletion commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
var logger = stdLog.New(os.Stderr, "", stdLog.LstdFlags)

// init command factory
func initComands() map[string]cli.CommandFactory {
func initCommands() map[string]cli.CommandFactory {
// register sub commands
return map[string]cli.CommandFactory{
"check": func() (cli.Command, error) {
Expand Down
4 changes: 2 additions & 2 deletions common/dns/godaddy/godaddy.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ func parseError(resp *http.Response) error {

// attempt process error body
if err = json.NewDecoder(resp.Body).Decode(obj); err != nil {
return fmt.Errorf("Unable to process error from %d error response: %s",
resp.StatusCode, err.Error())
return fmt.Errorf("unable decode %d error response: %w",
resp.StatusCode, err)
}

// check for fields
Expand Down
6 changes: 3 additions & 3 deletions common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
)

// ErrUnknownArg is returned when non-flag arguments are present after the command
var ErrUnknownArg = errors.New("Unknown non-flag argument(s) present after command")
var ErrUnknownArg = errors.New("unknown non-flag argument(s) present after command")

// ErrUnknownIPBackend is returned when an unknown IP backend is specified on the cli
var ErrUnknownIPBackend = errors.New("Unknown IP backend specified for command")
var ErrUnknownIPBackend = errors.New("unknown IP backend specified for command")

// ErrUnknownDNSBackend is returned when an unknown DNS backend is specified on the cli
var ErrUnknownDNSBackend = errors.New("Unknown DNS backend specified for command")
var ErrUnknownDNSBackend = errors.New("unknown DNS backend specified for command")
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func main() {

// init and populate cli object
c = cli.NewCLI(appName, appVersion)
c.Args = os.Args[1:] // arguments minus command
c.Commands = initComands() // see commands.go
c.Args = os.Args[1:] // arguments minus command
c.Commands = initCommands() // see commands.go

// run command and check return
if status, err = c.Run(); err != nil {
Expand Down

0 comments on commit c482abb

Please sign in to comment.