From 94f49640b477ff99e1918adcf4fc7796b2445861 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Sun, 16 Apr 2017 20:50:06 -0400 Subject: [PATCH] cmd/ofx: `golint` --- cmd/ofx/bankdownload.go | 4 ++-- cmd/ofx/banktransactions.go | 4 ++-- cmd/ofx/ccdownload.go | 4 ++-- cmd/ofx/cctransactions.go | 4 ++-- cmd/ofx/command.go | 4 ++-- cmd/ofx/detect_settings.go | 4 ++-- cmd/ofx/get_accounts.go | 4 ++-- cmd/ofx/invdownload.go | 4 ++-- cmd/ofx/invtransactions.go | 6 ++---- cmd/ofx/main.go | 8 ++++---- cmd/ofx/util.go | 2 +- 11 files changed, 23 insertions(+), 25 deletions(-) diff --git a/cmd/ofx/bankdownload.go b/cmd/ofx/bankdownload.go index 2c95ea0..d01965f 100644 --- a/cmd/ofx/bankdownload.go +++ b/cmd/ofx/bankdownload.go @@ -8,7 +8,7 @@ import ( "os" ) -var downloadCommand = Command{ +var downloadCommand = command{ Name: "download-bank", Description: "Download a bank account statement to a file", Flags: flag.NewFlagSet("download-bank", flag.ExitOnError), @@ -38,7 +38,7 @@ func downloadCheckFlags() bool { } func download() { - client, query := NewRequest() + client, query := newRequest() acctTypeEnum, err := ofxgo.NewAcctType(acctType) if err != nil { diff --git a/cmd/ofx/banktransactions.go b/cmd/ofx/banktransactions.go index 16bb4c6..9b42291 100644 --- a/cmd/ofx/banktransactions.go +++ b/cmd/ofx/banktransactions.go @@ -7,7 +7,7 @@ import ( "os" ) -var bankTransactionsCommand = Command{ +var bankTransactionsCommand = command{ Name: "transactions-bank", Description: "Print bank transactions and balance", Flags: flag.NewFlagSet("transactions-bank", flag.ExitOnError), @@ -23,7 +23,7 @@ func init() { } func bankTransactions() { - client, query := NewRequest() + client, query := newRequest() acctTypeEnum, err := ofxgo.NewAcctType(acctType) if err != nil { diff --git a/cmd/ofx/ccdownload.go b/cmd/ofx/ccdownload.go index 2c36228..a0b8174 100644 --- a/cmd/ofx/ccdownload.go +++ b/cmd/ofx/ccdownload.go @@ -8,7 +8,7 @@ import ( "os" ) -var ccDownloadCommand = Command{ +var ccDownloadCommand = command{ Name: "download-cc", Description: "Download a credit card account statement to a file", Flags: flag.NewFlagSet("download-cc", flag.ExitOnError), @@ -34,7 +34,7 @@ func ccDownloadCheckFlags() bool { } func ccDownload() { - client, query := NewRequest() + client, query := newRequest() uid, err := ofxgo.RandomUID() if err != nil { diff --git a/cmd/ofx/cctransactions.go b/cmd/ofx/cctransactions.go index 96c9253..9b98269 100644 --- a/cmd/ofx/cctransactions.go +++ b/cmd/ofx/cctransactions.go @@ -7,7 +7,7 @@ import ( "os" ) -var ccTransactionsCommand = Command{ +var ccTransactionsCommand = command{ Name: "transactions-cc", Description: "Print credit card transactions and balance", Flags: flag.NewFlagSet("transactions-cc", flag.ExitOnError), @@ -21,7 +21,7 @@ func init() { } func ccTransactions() { - client, query := NewRequest() + client, query := newRequest() uid, err := ofxgo.RandomUID() if err != nil { diff --git a/cmd/ofx/command.go b/cmd/ofx/command.go index c315e24..5d5b9f3 100644 --- a/cmd/ofx/command.go +++ b/cmd/ofx/command.go @@ -6,7 +6,7 @@ import ( "github.com/howeyc/gopass" ) -type Command struct { +type command struct { Name string Description string Flags *flag.FlagSet @@ -14,7 +14,7 @@ type Command struct { Do func() // Run the command (only called if CheckFlags returns true) } -func (c *Command) Usage() { +func (c *command) usage() { fmt.Printf("Usage of %s:\n", c.Name) c.Flags.PrintDefaults() } diff --git a/cmd/ofx/detect_settings.go b/cmd/ofx/detect_settings.go index 61c2d8d..f2cf644 100644 --- a/cmd/ofx/detect_settings.go +++ b/cmd/ofx/detect_settings.go @@ -8,7 +8,7 @@ import ( "time" ) -var detectSettingsCommand = Command{ +var detectSettingsCommand = command{ Name: "detect-settings", Description: "Attempt to guess client settings needed for a particular financial institution", Flags: flag.NewFlagSet("detect-settings", flag.ExitOnError), @@ -104,7 +104,7 @@ func detectSettings() { fmt.Printf("noindent: %t\n", noIndent) os.Exit(0) } else { - attempts += 1 + attempts++ var noIndentString string if noIndent { noIndentString = " noindent" diff --git a/cmd/ofx/get_accounts.go b/cmd/ofx/get_accounts.go index 77f4d68..049e8c4 100644 --- a/cmd/ofx/get_accounts.go +++ b/cmd/ofx/get_accounts.go @@ -8,7 +8,7 @@ import ( "time" ) -var getAccountsCommand = Command{ +var getAccountsCommand = command{ Name: "get-accounts", Description: "List accounts at your financial institution", Flags: flag.NewFlagSet("get-accounts", flag.ExitOnError), @@ -21,7 +21,7 @@ func init() { } func getAccounts() { - client, query := NewRequest() + client, query := newRequest() uid, err := ofxgo.RandomUID() if err != nil { diff --git a/cmd/ofx/invdownload.go b/cmd/ofx/invdownload.go index c2324e1..704292d 100644 --- a/cmd/ofx/invdownload.go +++ b/cmd/ofx/invdownload.go @@ -8,7 +8,7 @@ import ( "os" ) -var invDownloadCommand = Command{ +var invDownloadCommand = command{ Name: "download-inv", Description: "Download a investment account statement to a file", Flags: flag.NewFlagSet("download-inv", flag.ExitOnError), @@ -37,7 +37,7 @@ func invDownloadCheckFlags() bool { } func invDownload() { - client, query := NewRequest() + client, query := newRequest() uid, err := ofxgo.RandomUID() if err != nil { diff --git a/cmd/ofx/invtransactions.go b/cmd/ofx/invtransactions.go index 9b48fc8..f1a60f6 100644 --- a/cmd/ofx/invtransactions.go +++ b/cmd/ofx/invtransactions.go @@ -7,7 +7,7 @@ import ( "os" ) -var invTransactionsCommand = Command{ +var invTransactionsCommand = command{ Name: "transactions-inv", Description: "Print investment transactions", Flags: flag.NewFlagSet("transactions-inv", flag.ExitOnError), @@ -22,7 +22,7 @@ func init() { } func invTransactions() { - client, query := NewRequest() + client, query := newRequest() uid, err := ofxgo.RandomUID() if err != nil { @@ -47,8 +47,6 @@ func invTransactions() { response, err := client.Request(query) if err != nil { - fmt.Println("Error requesting account statement:", err) - os.Exit(1) } diff --git a/cmd/ofx/main.go b/cmd/ofx/main.go index 4d30c2e..26da3d8 100644 --- a/cmd/ofx/main.go +++ b/cmd/ofx/main.go @@ -6,7 +6,7 @@ import ( "strconv" ) -var commands = []Command{ +var commands = []command{ getAccountsCommand, downloadCommand, ccDownloadCommand, @@ -39,17 +39,17 @@ The commands are:`) } } -func runCmd(c *Command) { +func runCmd(c *command) { err := c.Flags.Parse(os.Args[2:]) if err != nil { fmt.Printf("Error parsing flags: %s\n", err) - c.Usage() + c.usage() os.Exit(1) } if !c.CheckFlags() { fmt.Println() - c.Usage() + c.usage() os.Exit(1) } diff --git a/cmd/ofx/util.go b/cmd/ofx/util.go index a8b991d..7676934 100644 --- a/cmd/ofx/util.go +++ b/cmd/ofx/util.go @@ -4,7 +4,7 @@ import ( "github.com/aclindsa/ofxgo" ) -func NewRequest() (*ofxgo.Client, *ofxgo.Request) { +func newRequest() (*ofxgo.Client, *ofxgo.Request) { var client = ofxgo.Client{ AppID: appID, AppVer: appVer,