Skip to content

Commit 054c990

Browse files
Refactor to improve styling and simplify the running of commands (#3)
* Refactor to improve styling and simplify the running of commands * go version for CI * golangci-lint-version * remove pointless getter
1 parent b37c08d commit 054c990

24 files changed

Lines changed: 1042 additions & 856 deletions

.github/workflows/ci.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,42 @@ name: CI
22

33
on:
44
push:
5-
branches:
5+
branches:
66
- main
77
pull_request:
8-
branches:
8+
branches:
99
- main
1010

1111
jobs:
1212
lint:
1313
name: Linting
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v4
17-
- uses: actions/setup-go@v5
18-
with:
19-
go-version: "1.22.2"
20-
- name: Lint Server
21-
uses: golangci/golangci-lint-action@v6
22-
with:
23-
working-directory: server
24-
version: v1.58
25-
- name: Lint CLI
26-
uses: golangci/golangci-lint-action@v6
27-
with:
28-
working-directory: backend-demo
29-
version: v1.58
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version: "1.25.4"
20+
- name: Lint Server
21+
uses: golangci/golangci-lint-action@v9
22+
with:
23+
working-directory: server
24+
version: v2.6
25+
- name: Lint CLI
26+
uses: golangci/golangci-lint-action@v9
27+
with:
28+
working-directory: backend-demo
29+
version: v2.6
3030

3131
test:
3232
name: Run Go Tests
3333
runs-on: ubuntu-latest
3434
steps:
35-
- uses: actions/checkout@v4
36-
- uses: actions/setup-go@v5
37-
with:
38-
go-version: "1.22.2"
39-
- name: Run tests
40-
run: |
41-
cd server
42-
go mod tidy
43-
go test ./... -cover -v
35+
- uses: actions/checkout@v4
36+
- uses: actions/setup-go@v5
37+
with:
38+
go-version: "1.25.4"
39+
- name: Run tests
40+
run: |
41+
cd server
42+
go mod tidy
43+
go test ./... -cover -v

.golangci.yaml

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
1+
version: "2"
12
run:
2-
timeout: 10m
3-
4-
# Run linters over integration tests
53
build-tags:
64
- integration
7-
85
linters:
9-
disable-all: true # Disable defaults, then enable the ones we want
6+
default: none
107
enable:
8+
- bodyclose
119
- errcheck
12-
- gosimple
10+
- gocritic
11+
- gosec
1312
- govet
1413
- ineffassign
15-
- typecheck
16-
- unused
17-
- bodyclose
18-
- stylecheck
19-
- gosec
20-
- goimports
21-
- gci
2214
- revive
23-
- gocritic
15+
- staticcheck
2416
- unconvert
25-
26-
linters-settings:
27-
goimports:
28-
local-prefixes: github.com/joshjennings98
29-
gci:
30-
sections:
31-
- Standard
32-
- Default
33-
- Prefix(github.com/joshjennings98)
34-
revive:
35-
rules:
36-
- name: exported
37-
severity: warning
38-
disabled: false
39-
arguments:
40-
- "disableStutteringCheck"
17+
- unused
18+
settings:
19+
revive:
20+
rules:
21+
- name: exported
22+
arguments:
23+
- disableStutteringCheck
24+
severity: warning
25+
disabled: false
26+
exclusions:
27+
generated: lax
28+
presets:
29+
- comments
30+
- common-false-positives
31+
- legacy
32+
- std-error-handling
33+
paths:
34+
- third_party$
35+
- builtin$
36+
- examples$
37+
formatters:
38+
enable:
39+
- gci
40+
- goimports
41+
settings:
42+
gci:
43+
sections:
44+
- Standard
45+
- Default
46+
- Prefix(github.com/joshjennings98)
47+
goimports:
48+
local-prefixes:
49+
- github.com/joshjennings98
50+
exclusions:
51+
generated: lax
52+
paths:
53+
- third_party$
54+
- builtin$
55+
- examples$

backend-demo/cmd/root.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ import (
1212
"github.com/joshjennings98/backend-demo/server/v2/server"
1313
)
1414

15-
var commandFile string
15+
var (
16+
commandFile string
17+
port int
18+
)
1619

1720
func init() {
1821
rootCmd.PersistentFlags().StringVarP(&commandFile, "command", "c", "", "Command file to use the presentation")
22+
rootCmd.PersistentFlags().IntVarP(&port, "port", "p", 8080, "Port to run server on")
23+
1924
_ = viper.BindPFlag("command", rootCmd.PersistentFlags().Lookup("command"))
25+
_ = viper.BindPFlag("port", rootCmd.PersistentFlags().Lookup("port"))
2026
}
2127

2228
var rootCmd = &cobra.Command{
@@ -31,7 +37,7 @@ var rootCmd = &cobra.Command{
3137

3238
logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
3339

34-
s, err := server.NewServer(logger, commandFile)
40+
s, err := server.NewServer(logger, port, commandFile)
3541
if err != nil {
3642
return
3743
}

backend-demo/go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/joshjennings98/backend-demo/backend-demo/v2
22

3-
go 1.22.2
3+
go 1.25.4
4+
5+
replace github.com/joshjennings98/backend-demo/server/v2 => ../server
46

57
require (
68
github.com/joshjennings98/backend-demo/server/v2 v2.1.1

server/go.mod

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/joshjennings98/backend-demo/server/v2
22

3-
go 1.22
3+
go 1.25.4
4+
5+
tool go.uber.org/mock/mockgen
46

57
require (
68
github.com/gorilla/websocket v1.5.1
@@ -14,6 +16,9 @@ require (
1416
require (
1517
github.com/davecgh/go-spew v1.1.1 // indirect
1618
github.com/pmezard/go-difflib v1.0.0 // indirect
19+
golang.org/x/mod v0.11.0 // indirect
1720
golang.org/x/net v0.25.0 // indirect
21+
golang.org/x/sys v0.20.0 // indirect
22+
golang.org/x/tools v0.2.0 // indirect
1823
gopkg.in/yaml.v3 v3.0.1 // indirect
1924
)

server/go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
1414
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
1515
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
1616
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
17+
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
18+
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
1719
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
1820
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
21+
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
22+
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
23+
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
24+
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
1925
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2026
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2127
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

0 commit comments

Comments
 (0)