cmd/ofx: `golint`

This commit is contained in:
Aaron Lindsay 2017-04-16 20:50:06 -04:00
parent 33c7ad463c
commit 94f49640b4
11 changed files with 23 additions and 25 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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()
}

View File

@ -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"

View File

@ -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 {

View File

@ -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 {

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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,