Skip to content

Commit 7132ec8

Browse files
committed
[doc] Fix golint issues in some files
1 parent 71f19c8 commit 7132ec8

File tree

6 files changed

+65
-41
lines changed

6 files changed

+65
-41
lines changed

internal/app/controller/apiServer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"net/http"
88
)
99

10-
// handle incoming web socket connections
10+
// WsHandler handles incoming web socket connections
1111
func WsHandler(w http.ResponseWriter, r *http.Request) {
1212
u := websocket.Upgrader{
1313
ReadBufferSize: 1024,

internal/app/controller/config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88
)
99

10-
// special configs that are different between normal and overtime halves
10+
// ConfigSpecial holds configs that are different between normal and overtime halves
1111
type ConfigSpecial struct {
1212
HalfDuration time.Duration `yaml:"half-duration"`
1313
HalfTimeDuration time.Duration `yaml:"half-time-duration"`
@@ -16,12 +16,12 @@ type ConfigSpecial struct {
1616
BreakAfter time.Duration `yaml:"break-after"`
1717
}
1818

19-
// global configs
19+
// ConfigGlobal holds configs that are valid for the whole game
2020
type ConfigGlobal struct {
2121
YellowCardDuration time.Duration `yaml:"yellow-card-duration"`
2222
}
2323

24-
// publish configs
24+
// ConfigPublish holds configs for publishing the state and commands to the teams
2525
type ConfigPublish struct {
2626
Address string `yaml:"address"`
2727
}
@@ -34,7 +34,7 @@ type Config struct {
3434
Overtime ConfigSpecial `yaml:"overtime"`
3535
}
3636

37-
// Load a config from given file
37+
// LoadConfig loads a config from given file
3838
func LoadConfig(fileName string) (config Config, err error) {
3939

4040
config = DefaultConfig()
@@ -55,7 +55,7 @@ func LoadConfig(fileName string) (config Config, err error) {
5555
return
5656
}
5757

58-
// Create a config with default values
58+
// DefaultConfig creates a config with default values
5959
func DefaultConfig() (c Config) {
6060
c.Publish.Address = "224.5.23.1:10003"
6161
c.Global.YellowCardDuration = 2 * time.Minute

internal/app/controller/publisher.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import (
1010

1111
const maxDatagramSize = 8192
1212

13+
// Publisher can publish state and commands to the teams
1314
type Publisher struct {
1415
conn *net.UDPConn
1516
message sslproto.SSL_Referee
1617
}
1718

18-
// Create a new publisher that publishes referee messages via UDP to the teams
19+
// NewPublisher creates a new publisher that publishes referee messages via UDP to the teams
1920
func NewPublisher(address string) (publisher Publisher, err error) {
2021
addr, err := net.ResolveUDPAddr("udp", address)
2122
if err != nil {

internal/app/controller/refBox.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func NewRefBox() (refBox *RefBox) {
3535
refBox.timer = timer.NewTimer()
3636
refBox.notifyUpdateState = make(chan struct{})
3737
refBox.MatchTimeStart = time.Unix(0, 0)
38-
refBox.State = NewRefBoxState(refBox.Config)
38+
refBox.State = NewState(refBox.Config)
3939
refBox.Publisher = loadPublisher(refBox.Config)
4040

4141
return

internal/app/controller/refBoxEvents.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func processEvent(event *RefBoxEvent) error {
114114

115115
func processTrigger(t *RefBoxEventTrigger) error {
116116
if t.Type == TriggerResetMatch {
117-
refBox.State = NewRefBoxState(refBox.Config)
117+
refBox.State = NewState(refBox.Config)
118118
refBox.MatchTimeStart = time.Unix(0, 0)
119119
} else if t.Type == TriggerSwitchColor {
120120
yellow := refBox.State.TeamState[TeamYellow]

internal/app/controller/state.go

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ import (
44
"time"
55
)
66

7-
// a team, one of Yellow or Blue
7+
// Team is one of Yellow or Blue
88
type Team string
99

1010
const (
11+
// TeamYellow is the yellow team
1112
TeamYellow Team = "Yellow"
12-
TeamBlue Team = "Blue"
13+
// TeamBlue is the blue team
14+
TeamBlue Team = "Blue"
1315
)
1416

15-
// return the other team
17+
// Other returns the other team
1618
// if the team is not Yellow or Blue, return the same team
1719
func (t Team) Other() Team {
1820
if t == TeamYellow {
@@ -23,27 +25,41 @@ func (t Team) Other() Team {
2325
return t
2426
}
2527

26-
// a stage of a match
28+
// Stage represents the different stages of a game
2729
type Stage string
2830

2931
const (
30-
StagePreGame Stage = "Pre-Game"
31-
StageFirstHalf Stage = "First Half"
32-
StageHalfTime Stage = "Half Time"
33-
StageSecondHalfPre Stage = "Pre-Second Half"
34-
StageSecondHalf Stage = "Second Half"
35-
StageOvertimeBreak Stage = "Overtime Break"
36-
StageOvertimeFirstHalfPre Stage = "Pre-Overtime First Half"
37-
StageOvertimeFirstHalf Stage = "Overtime First Half"
38-
StageOvertimeHalfTime Stage = "Overtime Half Time"
32+
// StagePreGame before game has started
33+
StagePreGame Stage = "Pre-Game"
34+
// StageFirstHalf in first half
35+
StageFirstHalf Stage = "First Half"
36+
// StageHalfTime in half time
37+
StageHalfTime Stage = "Half Time"
38+
// StageSecondHalfPre before second half
39+
StageSecondHalfPre Stage = "Pre-Second Half"
40+
// StageSecondHalf in second half
41+
StageSecondHalf Stage = "Second Half"
42+
// StageOvertimeBreak in break to overtime
43+
StageOvertimeBreak Stage = "Overtime Break"
44+
// StageOvertimeFirstHalfPre before first overtime half
45+
StageOvertimeFirstHalfPre Stage = "Pre-Overtime First Half"
46+
// StageOvertimeFirstHalf in first overtime half
47+
StageOvertimeFirstHalf Stage = "Overtime First Half"
48+
// StageOvertimeHalfTime in overtime half time
49+
StageOvertimeHalfTime Stage = "Overtime Half Time"
50+
// StageOvertimeSecondHalfPre before second overtime half
3951
StageOvertimeSecondHalfPre Stage = "Pre-Overtime Second Half"
40-
StageOvertimeSecondHalf Stage = "Overtime Second Half"
41-
StageShootoutBreak Stage = "Shootout Half Time"
42-
StageShootout Stage = "Shootout"
43-
StagePostGame Stage = "End of Game"
52+
// StageOvertimeSecondHalf in second overtime half
53+
StageOvertimeSecondHalf Stage = "Overtime Second Half"
54+
// StageShootoutBreak in break to shootout
55+
StageShootoutBreak Stage = "Shootout Break"
56+
// StageShootout in Shootout
57+
StageShootout Stage = "Shootout"
58+
// StagePostGame after game ended
59+
StagePostGame Stage = "End of Game"
4460
)
4561

46-
// all available stages, ordered
62+
// Stages include all available stages, ordered
4763
var Stages = []Stage{
4864
StagePreGame,
4965
StageFirstHalf,
@@ -61,20 +77,27 @@ var Stages = []Stage{
6177
StagePostGame,
6278
}
6379

64-
// a game state of a game
80+
// GameState of a game
6581
type GameState string
6682

6783
const (
68-
GameStateHalted GameState = "Halted"
69-
GameStateStopped GameState = "Stopped"
70-
GameStateRunning GameState = "Running"
71-
GameStatePreKickoff GameState = "Prepare Kickoff"
72-
GameStatePrePenalty GameState = "Prepare Penalty"
73-
GameStateTimeout GameState = "Timeout"
84+
// GameStateHalted halted
85+
GameStateHalted GameState = "Halted"
86+
// GameStateStopped stopped
87+
GameStateStopped GameState = "Stopped"
88+
// GameStateRunning running
89+
GameStateRunning GameState = "Running"
90+
// GameStatePreKickoff kickoff
91+
GameStatePreKickoff GameState = "Prepare Kickoff"
92+
// GameStatePrePenalty penalty
93+
GameStatePrePenalty GameState = "Prepare Penalty"
94+
// GameStateTimeout timeout
95+
GameStateTimeout GameState = "Timeout"
96+
// GameStateBallPlacement ball placement
7497
GameStateBallPlacement GameState = "Ball Placement"
7598
)
7699

77-
// team information
100+
// TeamInfo about a team
78101
type TeamInfo struct {
79102
Name string `json:"name"`
80103
Goals int `json:"goals"`
@@ -87,7 +110,7 @@ type TeamInfo struct {
87110
OnPositiveHalf bool `json:"onPositiveHalf"`
88111
}
89112

90-
// the state of the game
113+
// State of the game
91114
type State struct {
92115
Stage Stage `json:"stage"`
93116
GameState GameState `json:"gameState"`
@@ -98,8 +121,8 @@ type State struct {
98121
TeamState map[Team]*TeamInfo `json:"teamState"`
99122
}
100123

101-
// create a new state, initialized for the start of a new game
102-
func NewRefBoxState(config Config) (refBoxState *State) {
124+
// NewState creates a new state, initialized for the start of a new game
125+
func NewState(config Config) (refBoxState *State) {
103126
refBoxState = new(State)
104127
refBoxState.Stage = StagePreGame
105128
refBoxState.GameState = GameStateHalted
@@ -112,14 +135,14 @@ func NewRefBoxState(config Config) (refBoxState *State) {
112135
refBoxState.TeamState = map[Team]*TeamInfo{}
113136
refBoxState.TeamState[TeamYellow] = new(TeamInfo)
114137
refBoxState.TeamState[TeamBlue] = new(TeamInfo)
115-
*refBoxState.TeamState[TeamYellow] = NewTeamInfo(config)
116-
*refBoxState.TeamState[TeamBlue] = NewTeamInfo(config)
138+
*refBoxState.TeamState[TeamYellow] = newTeamInfo(config)
139+
*refBoxState.TeamState[TeamBlue] = newTeamInfo(config)
117140
refBoxState.TeamState[TeamBlue].OnPositiveHalf = !refBoxState.TeamState[TeamYellow].OnPositiveHalf
118141

119142
return
120143
}
121144

122-
func NewTeamInfo(config Config) (t TeamInfo) {
145+
func newTeamInfo(config Config) (t TeamInfo) {
123146
t.Name = ""
124147
t.Goals = 0
125148
t.Goalie = 0

0 commit comments

Comments
 (0)