From bde555532e405053cf70130732f2aa1491e4cfaf Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Sun, 21 Jul 2024 23:38:43 -0700 Subject: [PATCH] Switch to fork of gotext --- go.mod | 2 +- go.sum | 4 ++-- pkg/server/client.go | 2 +- pkg/server/database.go | 2 +- pkg/server/database_disabled.go | 2 +- pkg/server/server.go | 11 ++++------- pkg/server/server_command.go | 2 +- pkg/server/server_web.go | 2 ++ pkg/server/server_web_disabled.go | 7 +++++++ 9 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 pkg/server/server_web_disabled.go diff --git a/go.mod b/go.mod index fa53aeb..154472d 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,12 @@ module code.rocket9labs.com/tslocum/bgammon go 1.17 require ( + code.rocket9labs.com/tslocum/gotext v0.0.0-20240722063358-6067ad4d7a58 code.rocket9labs.com/tslocum/tabula v0.0.0-20240703054156-ce0b448f0999 github.com/alexedwards/argon2id v1.0.0 github.com/gorilla/mux v1.8.1 github.com/jackc/pgx/v5 v5.6.0 github.com/jlouis/glicko2 v1.0.0 - github.com/leonelquinteros/gotext v1.6.1 github.com/matcornic/hermes/v2 v2.1.0 golang.org/x/text v0.16.0 nhooyr.io/websocket v1.8.11 diff --git a/go.sum b/go.sum index 092604e..5e98c97 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b h1:Y0a14Kf/hSYepSmp4ZfDeE4CZZGBGBS97CNjCbKJm0c= code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b/go.mod h1:tS60/VNAJphKvDBkSLQhKALa15msIAuWWfEKNc4oFZc= +code.rocket9labs.com/tslocum/gotext v0.0.0-20240722063358-6067ad4d7a58 h1:8A+LPX/j9qYaE/tSJcaYONIh28JX5CN9i+4ZfRefvPo= +code.rocket9labs.com/tslocum/gotext v0.0.0-20240722063358-6067ad4d7a58/go.mod h1:ZkYZ/IF/ebzhUL2bNp4ALROsuH9iCztUWvUJBWsHXRU= code.rocket9labs.com/tslocum/tabula v0.0.0-20240703054156-ce0b448f0999 h1:PwfoDBtxVT3TwL2KpoijPKi6NQsGu6cXhPVoQeqKJWM= code.rocket9labs.com/tslocum/tabula v0.0.0-20240703054156-ce0b448f0999/go.mod h1:WEJXESKXqrMFLAArikQ79lpRibNeeE1C0VruxXYMF5M= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= @@ -54,8 +56,6 @@ github.com/jlouis/glicko2 v1.0.0/go.mod h1:5dzlxjhVPPLk+wiUwwF2oVyDwsNXMgnw7WrLR github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leonelquinteros/gotext v1.6.1 h1:PuTN8YUqHvfPZxW+fPXp7o0Fc2zN9L2wXBZrqT5MO5A= -github.com/leonelquinteros/gotext v1.6.1/go.mod h1:qQRISjoonXYFdRGrTG1LARQ38Gpibad0IPeB4hpvyyM= github.com/matcornic/hermes/v2 v2.1.0 h1:9TDYFBPFv6mcXanaDmRDEp/RTWj0dTTi+LpFnnnfNWc= github.com/matcornic/hermes/v2 v2.1.0/go.mod h1:2+ziJeoyRfaLiATIL8VZ7f9hpzH4oDHqTmn0bhrsgVI= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= diff --git a/pkg/server/client.go b/pkg/server/client.go index 66a52f4..75b3b15 100644 --- a/pkg/server/client.go +++ b/pkg/server/client.go @@ -9,7 +9,7 @@ import ( "time" "code.rocket9labs.com/tslocum/bgammon" - "github.com/leonelquinteros/gotext" + "code.rocket9labs.com/tslocum/gotext" ) type clientRating struct { diff --git a/pkg/server/database.go b/pkg/server/database.go index 9ac032b..b5779ba 100644 --- a/pkg/server/database.go +++ b/pkg/server/database.go @@ -1,4 +1,4 @@ -//go:build database +//go:build full package server diff --git a/pkg/server/database_disabled.go b/pkg/server/database_disabled.go index 606c340..2dd8ed5 100644 --- a/pkg/server/database_disabled.go +++ b/pkg/server/database_disabled.go @@ -1,4 +1,4 @@ -//go:build !database +//go:build !full package server diff --git a/pkg/server/server.go b/pkg/server/server.go index b12aa74..073f969 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -15,7 +15,6 @@ import ( "net/http" "os" "os/exec" - "reflect" "regexp" "sort" "strconv" @@ -24,7 +23,7 @@ import ( "time" "code.rocket9labs.com/tslocum/bgammon" - "github.com/leonelquinteros/gotext" + "code.rocket9labs.com/tslocum/gotext" "golang.org/x/text/language" ) @@ -112,12 +111,10 @@ func NewServer(tz string, dataSource string, mailServer string, passwordSalt str } s.loadLocales() - keys := reflect.ValueOf(bgammon.HelpText).MapKeys() - sortKeys := func(i, j int) bool { return keys[i].Interface().(string) < keys[j].Interface().(string) } - sort.Slice(keys, sortKeys) - for _, key := range keys { - s.sortedCommands = append(s.sortedCommands, key.Interface().(string)) + for command := range bgammon.HelpText { + s.sortedCommands = append(s.sortedCommands, command) } + sort.Slice(s.sortedCommands, func(i, j int) bool { return s.sortedCommands[i] < s.sortedCommands[j] }) if tz != "" { var err error diff --git a/pkg/server/server_command.go b/pkg/server/server_command.go index d4fe792..95c3aaa 100644 --- a/pkg/server/server_command.go +++ b/pkg/server/server_command.go @@ -9,7 +9,7 @@ import ( "time" "code.rocket9labs.com/tslocum/bgammon" - "github.com/leonelquinteros/gotext" + "code.rocket9labs.com/tslocum/gotext" ) var clearBytes = []byte("clear") diff --git a/pkg/server/server_web.go b/pkg/server/server_web.go index 0922c8d..aad88f5 100644 --- a/pkg/server/server_web.go +++ b/pkg/server/server_web.go @@ -1,3 +1,5 @@ +//go:build full + package server import ( diff --git a/pkg/server/server_web_disabled.go b/pkg/server/server_web_disabled.go new file mode 100644 index 0000000..0bc7014 --- /dev/null +++ b/pkg/server/server_web_disabled.go @@ -0,0 +1,7 @@ +//go:build !full + +package server + +func (s *server) listenWebSocket(address string) { + // Do nothing. +}