From 97da227777c9bbbf5e93e8e21072642c7ba6463f Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sun, 1 Dec 2019 20:53:13 -0700 Subject: [PATCH] go fmt --- cmd/mothd/state.go | 26 +++++++++++++------------- cmd/mothd/state_test.go | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cmd/mothd/state.go b/cmd/mothd/state.go index 551a89d..c855264 100644 --- a/cmd/mothd/state.go +++ b/cmd/mothd/state.go @@ -116,20 +116,20 @@ func (s *State) TeamName(teamId string) (string, error) { // Write out team name. This can only be done once. func (s *State) SetTeamName(teamId string, teamName string) error { if f, err := s.fs.Open("teamids.txt"); err != nil { - return fmt.Errorf("Team IDs file does not exist") + return fmt.Errorf("Team IDs file does not exist") } else { - ok := false - scanner := bufio.NewScanner(f) - for scanner.Scan() { - if scanner.Text() == teamId { - ok = true - break - } - } - f.Close() - if !ok { - return fmt.Errorf("Team ID not found in list of valid Team IDs") - } + found := false + scanner := bufio.NewScanner(f) + for scanner.Scan() { + if scanner.Text() == teamId { + found = true + break + } + } + f.Close() + if !found { + return fmt.Errorf("Team ID not found in list of valid Team IDs") + } } teamFile := filepath.Join("teams", teamId) diff --git a/cmd/mothd/state_test.go b/cmd/mothd/state_test.go index 90defdc..9efd4c1 100644 --- a/cmd/mothd/state_test.go +++ b/cmd/mothd/state_test.go @@ -1,7 +1,7 @@ package main import ( - "bytes" + "bytes" "github.com/spf13/afero" "os" "testing" @@ -20,31 +20,31 @@ func TestState(t *testing.T) { s := NewState(fs) s.Cleanup() - pl := s.PointsLog() - if len(pl) != 0 { - t.Errorf("Empty points log is not empty") - } + pl := s.PointsLog() + if len(pl) != 0 { + t.Errorf("Empty points log is not empty") + } mustExist("initialized") mustExist("enabled") mustExist("hours") - + teamidsBuf, err := afero.ReadFile(fs, "teamids.txt") if err != nil { - t.Errorf("Reading teamids.txt: %v", err) + t.Errorf("Reading teamids.txt: %v", err) } - + teamids := bytes.Split(teamidsBuf, []byte("\n")) if (len(teamids) != 101) || (len(teamids[100]) > 0) { - t.Errorf("There weren't 100 teamids, there were %d", len(teamids)) + t.Errorf("There weren't 100 teamids, there were %d", len(teamids)) } myTeam := string(teamids[0]) - + if err := s.SetTeamName("bad team ID", "bad team name"); err == nil { - t.Errorf("Setting bad team ID didn't raise an error") + t.Errorf("Setting bad team ID didn't raise an error") } - + if err := s.SetTeamName(myTeam, "My Team"); err != nil { - t.Errorf("Setting team name: %v", err) + t.Errorf("Setting team name: %v", err) } }