Skip to content

Commit

Permalink
Updated the comments to un-export functions
Browse files Browse the repository at this point in the history
Fixed the fuckery in the go 'url.Parse' function
 - I made a library to fix it @ 'github.com/PurpleSec/parseurl'
  • Loading branch information
iDigitalFlame committed Apr 5, 2020
1 parent 826ff72 commit fdf1512
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
6 changes: 2 additions & 4 deletions scoreboard/game/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ import (
)

var (
// ErrCannotSum is an error returned by the function 'Add'. This is returned when the passed interface is
// not a primitive type.
ErrCannotSum = errors.New("cannot hash the requested type")
errCannotSum = errors.New("cannot hash the requested type")

bufs = sync.Pool{
New: func() interface{} {
Expand Down Expand Up @@ -140,7 +138,7 @@ func (h *hasher) Hash(v interface{}) error {
h.Write([]byte(v.(fmt.Stringer).String()))
default:
bufs.Put(&b)
return fmt.Errorf("type %T: %w", v, ErrCannotSum)
return fmt.Errorf("type %T: %w", v, errCannotSum)
}
bufs.Put(&b)
return nil
Expand Down
18 changes: 9 additions & 9 deletions scoreboard/game/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ import (
"time"

"github.com/PurpleSec/logx"
"github.com/PurpleSec/parseurl"
"github.com/dghubble/go-twitter/twitter"
"github.com/gorilla/websocket"
"github.com/stvp/slug"
)

// ErrMissingGame is returned when attempting to Unmarshal a Hello struct that does not contain a Game ID mapping.
var ErrMissingGame = errors.New("game ID is missing from JSON data")
var errMissingGame = errors.New("game ID is missing from JSON data")

type hello uint64
type tweet struct {
Expand Down Expand Up @@ -133,11 +133,11 @@ func (m *Manager) New(n *websocket.Conn) {
if !ok || s == nil {
m.log.Debug("Checking Game ID %d, requested by %q...", h, n.RemoteAddr().String())
var g game
//if err := m.getJSON(context.Background(), fmt.Sprintf("api/scoreboard/%d/", h), &g); err != nil {
// m.log.Error("Error retriving data for Game ID %d: %s!", h, err.Error())
// n.Close()
// return
//}
if err := m.getJSON(context.Background(), fmt.Sprintf("api/scoreboard/%d/", h), &g); err != nil {
m.log.Error("Error retriving data for Game ID %d: %s!", h, err.Error())
n.Close()
return
}
if len(g.Meta.Name) == 0 && len(g.Teams) == 0 {
m.log.Error("Game ID %d is empty, ignoring!", h)
n.Close()
Expand Down Expand Up @@ -245,7 +245,7 @@ func (h *hello) UnmarshalJSON(b []byte) error {
}
v, ok := m["game"]
if !ok {
return ErrMissingGame
return errMissingGame
}
*h = hello(v)
return nil
Expand Down Expand Up @@ -439,7 +439,7 @@ func (m Manager) getJSON(x context.Context, u string, o interface{}) error {

// New creates a collection instance from the provided logger, timeout and API URL endpoint.
func New(burl, d string, tick, t time.Duration, l logx.Log) (*Manager, error) {
u, err := url.Parse(burl)
u, err := parseurl.Parse(burl)
if err != nil {
return nil, fmt.Errorf("could not unpack provided URL %q: %w", burl, err)
}
Expand Down
2 changes: 1 addition & 1 deletion scoreboard/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ go 1.13
require (
blainsmith.com/go/seahash v1.1.3
github.com/PurpleSec/logx v1.0.0
github.com/PurpleSec/parseurl v1.0.1
github.com/dghubble/go-twitter v0.0.0-20190719072343-39e5462e111f
github.com/dghubble/oauth1 v0.6.0
github.com/gobuffalo/packr/v2 v2.5.2
github.com/gorilla/websocket v1.4.0
github.com/iDigitalFlame/logx/logx v0.0.0-20190906173944-19f08e71816b
github.com/stvp/slug v0.0.0-20150928221549-5ab8191bb1fe
golang.org/x/text v0.3.2 // indirect
)
7 changes: 2 additions & 5 deletions scoreboard/go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
blainsmith.com/go/seahash v1.1.3 h1:cfP2r+LhlIqSlYp+UY1yNJKmRttdP+kP4fLhYqAf1co=
blainsmith.com/go/seahash v1.1.3/go.mod h1:pnKU6FdQMfYOGoDBo5FPdlZG7kmOJ/nuNyfu0czty8k=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/PurpleSec/logx v0.0.0-20200330031647-70b461978847 h1:uVKr9CYKtUqKLoj20YG1me7TpVSr9Si8WrmUMTNk/uA=
github.com/PurpleSec/logx v0.0.0-20200330031647-70b461978847/go.mod h1:tkLK6CqkhkRSVejDMVgZa0jTq97aRikVNjAON9iUiK0=
github.com/PurpleSec/logx v1.0.0 h1:gffIzRnADlWxzblLF0auhNjfWCl2CJsbF8Tb8O3of+U=
github.com/PurpleSec/logx v1.0.0/go.mod h1:tkLK6CqkhkRSVejDMVgZa0jTq97aRikVNjAON9iUiK0=
github.com/PurpleSec/parseurl v1.0.1 h1:pxni8f2FvC6hbK/z9XD2/GhLFbHqjOYekCwue503zEs=
github.com/PurpleSec/parseurl v1.0.1/go.mod h1:mZgE03Iv0LBkLPItVE7HnYhaFLXqBRdkl5XZXsKt5wc=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/cenkalti/backoff v2.1.1+incompatible h1:tKJnvO2kl0zmb/jA5UKAt4VoEVw1qxKWjE/Bpp46npY=
github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
Expand Down Expand Up @@ -36,9 +36,6 @@ github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/iDigitalFlame/logx/logx v0.0.0-20190906173944-19f08e71816b h1:miO+rm71ShHFYml7Q9X5+uIrXtC8yEpSaimqNJN/2n0=
github.com/iDigitalFlame/logx/logx v0.0.0-20190906173944-19f08e71816b/go.mod h1:CVj7ZH5KPHNoh4WdOXH4pfaQg3YHRMaTqtAmFHvu1tI=
github.com/iDigitalFlame/scorebot-scoreboard v0.0.0-20200130012850-e7847955d4c0 h1:2PmBjSuOvSc9e2Rnz7NyVu+T8nMQ2a6XcXZEe+r1/Ok=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
Expand Down

0 comments on commit fdf1512

Please sign in to comment.