Browse Source

Fix vet warnings

master
Trevor Slocum 2 years ago
parent
commit
a4efa04683
  1. 6
      README.md
  2. 25
      client.go
  3. 2
      game.go

6
README.md

@ -6,7 +6,11 @@ Cribbage server @@ -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

25
client.go

@ -11,9 +11,16 @@ import ( @@ -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() { @@ -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() { @@ -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() { @@ -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 != "" {

2
game.go

@ -898,5 +898,5 @@ func (g *Game) logDebug(args ...interface{}) { @@ -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))
}

Loading…
Cancel
Save