Skip to content

Commit 8917d0d

Browse files
committed
Added goreleaser config
Reverted to statik, more lightweight and easier for cross compilation
1 parent ef0f5cb commit 8917d0d

7 files changed

Lines changed: 63 additions & 33 deletions

File tree

.goreleaser.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
before:
2+
hooks:
3+
- go mod download
4+
- go generate ./...
5+
builds:
6+
- env:
7+
- CGO_ENABLED=0
8+
goos:
9+
- linux
10+
- darwin
11+
- windows
12+
archives:
13+
- replacements:
14+
darwin: Darwin
15+
linux: Linux
16+
windows: Windows
17+
386: i386
18+
amd64: x86_64
19+
checksum:
20+
name_template: 'checksums.txt'
21+
snapshot:
22+
name_template: "{{ .Tag }}-next"
23+
changelog:
24+
sort: asc
25+
filters:
26+
exclude:
27+
- '^docs:'
28+
- '^test:'

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module github.com/ts2/ts2-sim-server
22

33
require (
4-
github.com/GeertJohan/go.rice v1.0.0
54
github.com/go-stack/stack v1.8.0 // indirect
65
github.com/gorilla/websocket v1.4.0
76
github.com/mattn/go-colorable v0.1.1 // indirect
87
github.com/mattn/go-isatty v0.0.7 // indirect
8+
github.com/rakyll/statik v0.1.6
99
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a
1010
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec
1111
)

go.sum

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,22 @@
1-
github.com/GeertJohan/go.incremental v1.0.0 h1:7AH+pY1XUgQE4Y1HcXYaMqAI0m9yrFqo/jt0CW30vsg=
2-
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
3-
github.com/GeertJohan/go.rice v1.0.0 h1:KkI6O9uMaQU3VEKaj01ulavtF7o1fWT7+pk/4voiMLQ=
4-
github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0=
5-
github.com/akavel/rsrc v0.8.0 h1:zjWn7ukO9Kc5Q62DOJCcxGpXC18RawVtYAGdz2aLlfw=
6-
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
7-
github.com/daaku/go.zipexe v1.0.0 h1:VSOgZtH418pH9L16hC/JrgSNJbbAL26pj7lmD1+CGdY=
8-
github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E=
9-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
101
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
112
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
123
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
134
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
145
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
156
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
16-
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
17-
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
187
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
198
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
209
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
2110
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
2211
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
2312
github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc=
2413
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
25-
github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229 h1:E2B8qYyeSgv5MXpmzZXRNp8IAQ4vjxIjhpAf5hv/tAg=
26-
github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E=
2714
github.com/rakyll/statik v0.1.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs=
2815
github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs=
2916
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
3017
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
3118
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs=
3219
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
33-
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
34-
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
35-
github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8=
36-
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
3720
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
3821
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
3922
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

server/connection_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828

2929
func TestConnection(t *testing.T) {
3030
// Wait for server to come up
31-
time.Sleep(100 * time.Millisecond)
31+
time.Sleep(900 * time.Millisecond)
3232
Convey("Testing server connection", t, func() {
3333
c := clientDial(t)
3434
Convey("Login test", func() {

server/http.go

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@
1616
// Free Software Foundation, Inc.,
1717
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1818

19+
//go:generate statik -src=../static
20+
1921
package server
2022

2123
import (
2224
"fmt"
2325
"html/template"
26+
"io/ioutil"
2427
"net/http"
2528
"os"
2629
"time"
2730

28-
rice "github.com/GeertJohan/go.rice"
31+
"github.com/rakyll/statik/fs"
32+
_ "github.com/ts2/ts2-sim-server/server/statik"
2933
"github.com/ts2/ts2-sim-server/simulation"
3034
log "gopkg.in/inconshreveable/log15.v2"
3135
)
@@ -37,16 +41,11 @@ const (
3741
)
3842

3943
var (
40-
sim *simulation.Simulation
41-
hub *Hub
42-
logger log.Logger
43-
staticBox *rice.Box
44+
sim *simulation.Simulation
45+
hub *Hub
46+
logger log.Logger
4447
)
4548

46-
func init() {
47-
staticBox = rice.MustFindBox("../static")
48-
}
49-
5049
// InitializeLogger creates the logger for the server module
5150
func InitializeLogger(parentLogger log.Logger) {
5251
logger = parentLogger.New("module", "server")
@@ -75,8 +74,19 @@ func Run(s *simulation.Simulation, addr, port string) {
7574
//
7675
// /ws - WebSocket endpoint for all TS2 clients and managers.
7776
func HttpdStart(addr, port string) {
77+
statikFS, err := fs.New()
78+
if err != nil {
79+
logger.Crit("Unable to read statik FS", "error", err)
80+
return
81+
}
82+
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(statikFS)))
7883

79-
homeTemplData, err := staticBox.String("/index.html")
84+
homeTemplFile, err := statikFS.Open("/index.html")
85+
if err != nil {
86+
logger.Crit("Unable to read index.html from statikFS", "error", err)
87+
return
88+
}
89+
homeTemplData, err := ioutil.ReadAll(homeTemplFile)
8090
if err != nil {
8191
logger.Crit("Unable to open `index.html` ", "error", err)
8292
return
@@ -86,9 +96,6 @@ func HttpdStart(addr, port string) {
8696
http.HandleFunc("/", serveHome)
8797
http.HandleFunc("/ws", serveWs)
8898

89-
staticFileServer := http.StripPrefix("/static/", http.FileServer(staticBox.HTTPBox()))
90-
http.Handle("/static/", staticFileServer)
91-
9299
serverAddress := fmt.Sprintf("%s:%s", addr, port)
93100
logger.Info("Starting HTTP", "submodule", "http", "address", serverAddress)
94101
err = http.ListenAndServe(serverAddress, nil)

server/http_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
func TestHTTP(t *testing.T) {
1515
// Wait for server to come up
16-
time.Sleep(100 * time.Millisecond)
16+
time.Sleep(500 * time.Millisecond)
1717
Convey("Testing HTTP websocket client", t, func() {
1818
Convey("Normal GET / ", func() {
1919
res, err := http.Get("http://127.0.0.1:22222")

server/statik/statik.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)