Skip to content

Commit b7f6a94

Browse files
committed
[doc] Fix golint issues in more files
1 parent 7132ec8 commit b7f6a94

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

internal/app/controller/refBox.go

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const configFileName = "config/ssl-game-controller.yaml"
1515

1616
var refBox = NewRefBox()
1717

18+
// RefBox controls a game
1819
type RefBox struct {
1920
State *State
2021
timer timer.Timer
@@ -28,6 +29,7 @@ type RefBox struct {
2829
Publisher Publisher
2930
}
3031

32+
// NewRefBox creates a new refBox
3133
func NewRefBox() (refBox *RefBox) {
3234

3335
refBox = new(RefBox)
@@ -41,26 +43,12 @@ func NewRefBox() (refBox *RefBox) {
4143
return
4244
}
4345

44-
func loadPublisher(config Config) Publisher {
45-
publisher, err := NewPublisher(config.Publish.Address)
46-
if err != nil {
47-
log.Printf("Could not start publisher on %v. %v", config.Publish.Address, err)
48-
}
49-
return publisher
50-
}
51-
52-
func loadConfig() Config {
53-
config, err := LoadConfig(configFileName)
54-
if err != nil {
55-
log.Printf("Warning: Could not load config: %v", err)
56-
}
57-
return config
58-
}
59-
46+
// RunRefBox starts the global refBox
6047
func RunRefBox() {
6148
refBox.Run()
6249
}
6350

51+
// Run the refBox by loading configs, states, timer, etc.
6452
func (r *RefBox) Run() (err error) {
6553

6654
os.MkdirAll(logDir, os.ModePerm)
@@ -85,6 +73,22 @@ func (r *RefBox) Run() (err error) {
8573
return nil
8674
}
8775

76+
func loadPublisher(config Config) Publisher {
77+
publisher, err := NewPublisher(config.Publish.Address)
78+
if err != nil {
79+
log.Printf("Could not start publisher on %v. %v", config.Publish.Address, err)
80+
}
81+
return publisher
82+
}
83+
84+
func loadConfig() Config {
85+
config, err := LoadConfig(configFileName)
86+
if err != nil {
87+
log.Printf("Warning: Could not load config: %v", err)
88+
}
89+
return config
90+
}
91+
8892
func (r *RefBox) openStateFiles() {
8993
stateHistoryLogFileName := logDir + "/state-history_" + time.Now().Format("2006-01-02_15-04-05") + ".log"
9094
f, err := os.OpenFile(stateHistoryLogFileName, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
@@ -117,6 +121,7 @@ func (r *RefBox) readLastState() {
117121
}
118122
}
119123

124+
// Tick updates the times of the state and removes cards, if necessary
120125
func (r *RefBox) Tick() {
121126
delta := r.timer.Delta()
122127
updateTimes(r, delta)
@@ -126,16 +131,19 @@ func (r *RefBox) Tick() {
126131
}
127132
}
128133

134+
// Update publishes the state to the UI and the teams
129135
func (r *RefBox) Update(command *RefBoxEventCommand) {
130136
r.notifyUpdateState <- struct{}{}
131137
refBox.Publisher.Publish(refBox.State, command)
132138
}
133139

140+
// SaveState writes the latest state out and logs the state history
134141
func (r *RefBox) SaveState() {
135142
r.SaveLatestState()
136143
r.SaveStateHistory()
137144
}
138145

146+
// SaveLatestState writes the current state into a file
139147
func (r *RefBox) SaveLatestState() {
140148
jsonState, err := json.MarshalIndent(r.State, "", " ")
141149
if err != nil {
@@ -154,6 +162,7 @@ func (r *RefBox) SaveLatestState() {
154162
r.lastStateFile.Sync()
155163
}
156164

165+
// SaveStateHistory writes the current state to the history file
157166
func (r *RefBox) SaveStateHistory() {
158167

159168
r.StateHistory = append(r.StateHistory, *r.State)
@@ -169,13 +178,15 @@ func (r *RefBox) SaveStateHistory() {
169178
r.stateHistoryFile.Sync()
170179
}
171180

181+
// UndoLastAction restores the last state from internal history
172182
func (r *RefBox) UndoLastAction() {
173183
lastIndex := len(r.StateHistory) - 2
174184
if lastIndex >= 0 {
175185
*r.State = r.StateHistory[lastIndex]
176186
r.StateHistory = r.StateHistory[0:lastIndex]
177187
}
178188
}
189+
179190
func (r *RefBox) loadStages() {
180191
r.StageTimes = map[Stage]time.Duration{}
181192
for _, stage := range Stages {

internal/app/controller/refBoxEvents.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,8 @@ func processEvent(event *RefBoxEvent) error {
106106
return processStage(event.Stage)
107107
} else if event.Trigger != nil {
108108
return processTrigger(event.Trigger)
109-
} else {
110-
return errors.New("Unknown event.")
111109
}
112-
return nil
110+
return errors.New("Unknown event.")
113111
}
114112

115113
func processTrigger(t *RefBoxEventTrigger) error {

0 commit comments

Comments
 (0)