Fix vet warnings

This commit is contained in:
Trevor Slocum 2020-08-14 09:36:31 -07:00
parent 9fb58ec777
commit a4efa04683
3 changed files with 22 additions and 11 deletions

View file

@ -6,7 +6,11 @@ Cribbage server
## Demo
[Cribbage.World](https://cribbage.world) is powered by jack.
[**Cribbage.World**](https://cribbage.world) is powered by jack.
```bash
ssh cribbage.world -p 22000
```
## Support

View file

@ -11,9 +11,16 @@ import (
"gitlab.com/tslocum/joker"
)
const ClientTerminating = -1
const ClientTelnet = 1
const ClientWebsocket = 2
const (
ClientTerminating = -1
ClientTelnet = 1
ClientWebsocket = 2
)
const (
trimNewlinesAndSpace = " \r\n\x00"
trimNewlines = "\r\n\x00"
)
type Client struct {
ConnType int
@ -46,8 +53,8 @@ func (c *Client) processRead() {
}
handled = false
command = strings.TrimLeft(command, " \r\n"+string(0))
command = strings.TrimRight(command, " \r\n"+string(0))
command = strings.TrimLeft(command, trimNewlinesAndSpace)
command = strings.TrimRight(command, trimNewlinesAndSpace)
command_pieces = strings.Fields(strings.ToLower(command))
if len(command_pieces) > 0 {
handled = true
@ -56,8 +63,8 @@ func (c *Client) processRead() {
if len(command_pieces) > 1 {
for i := 1; i < len(command_pieces); i++ {
command_piece := command_pieces[i]
command_piece = strings.TrimLeft(command_piece, " \r\n"+string(0))
command_piece = strings.TrimRight(command_piece, " \r\n"+string(0))
command_piece = strings.TrimLeft(command_piece, trimNewlinesAndSpace)
command_piece = strings.TrimRight(command_piece, trimNewlinesAndSpace)
if command_piece != "" {
if args != "" {
@ -124,9 +131,9 @@ func (c *Client) handleRead() {
break
}
readtext += strings.TrimLeft(string(buf), "\r\n"+string(0))
readtext += strings.TrimLeft(string(buf), trimNewlines)
for {
readtext = strings.TrimLeft(readtext, "\r\n"+string(0))
readtext = strings.TrimLeft(readtext, trimNewlines)
nextline = strings.Index(readtext, "\n")
if nextline <= 0 {
if readtext != "" {

View file

@ -898,5 +898,5 @@ func (g *Game) logDebug(args ...interface{}) {
}
func cleanIdentifier(cardidentifier string) string {
return strings.ToLower(strings.TrimLeft(strings.TrimRight(cardidentifier, " \r\n"+string(0)), " \r\n"+string(0)))
return strings.ToLower(strings.Trim(cardidentifier, trimNewlinesAndSpace))
}