refactor: replace all bare command string literals with named constants
All checks were successful
check / check (push) Successful in 2m15s
All checks were successful
check / check (push) Successful in 2m15s
Extract cmdLusers, cmdMode, cmdMotd, cmdNames, cmdNotice, cmdPing, cmdPong constants in internal/handlers/api.go. Add corresponding constants in cmd/neoirc-cli/main.go and cmd/neoirc-cli/api/client.go. Replace every bare IRC command string literal in switch cases and command dispatch code with the named constant. Zero bare command strings remain in any dispatch path.
This commit is contained in:
@@ -19,6 +19,9 @@ const (
|
||||
httpTimeout = 30 * time.Second
|
||||
pollExtraTime = 5
|
||||
httpErrThreshold = 400
|
||||
|
||||
cmdJoin = "JOIN"
|
||||
cmdPart = "PART"
|
||||
)
|
||||
|
||||
var errHTTP = errors.New("HTTP error")
|
||||
@@ -168,7 +171,7 @@ func (client *Client) PollMessages(
|
||||
func (client *Client) JoinChannel(channel string) error {
|
||||
return client.SendMessage(
|
||||
&Message{ //nolint:exhaustruct // only command+to needed
|
||||
Command: "JOIN", To: channel,
|
||||
Command: cmdJoin, To: channel,
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -177,7 +180,7 @@ func (client *Client) JoinChannel(channel string) error {
|
||||
func (client *Client) PartChannel(channel string) error {
|
||||
return client.SendMessage(
|
||||
&Message{ //nolint:exhaustruct // only command+to needed
|
||||
Command: "PART", To: channel,
|
||||
Command: cmdPart, To: channel,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user