Skip to content

Commit 75296b4

Browse files
committed
Chore: Enable golangci-lint
Add a GitHub actions workflow to run golangci-lint. Signed-off-by: SuperQ <[email protected]>
1 parent d3641bb commit 75296b4

File tree

9 files changed

+63
-23
lines changed

9 files changed

+63
-23
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: golangci-lint
3+
on:
4+
push:
5+
paths:
6+
- "go.sum"
7+
- "go.mod"
8+
- "**.go"
9+
- ".github/workflows/golangci-lint.yml"
10+
- ".golangci.yml"
11+
pull_request:
12+
13+
permissions: # added using https://github.com/step-security/secure-repo
14+
contents: read
15+
16+
jobs:
17+
golangci:
18+
permissions:
19+
contents: read # for actions/checkout to fetch code
20+
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
21+
name: lint
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
- name: Install Go
27+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
28+
with:
29+
go-version: 1.23.x
30+
- name: Lint
31+
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
32+
with:
33+
args: --verbose
34+
version: v1.62.0

.golangci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
linters:
3+
enable:
4+
# - goimports
5+
# - misspell
6+
# - revive
7+
8+
issues:
9+
exclude-rules:
10+
- path: _test.go
11+
linters:
12+
- errcheck

display.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func startBacklightTickers() {
211211
// Don't start the tickers if the display is switched off.
212212
// Set the display to off if that's the case.
213213
if config.DisplayMaxBrightness == 0 {
214-
setDisplayBrightness(0)
214+
_ = setDisplayBrightness(0)
215215
return
216216
}
217217

@@ -221,7 +221,7 @@ func startBacklightTickers() {
221221
defer dimTicker.Stop()
222222

223223
go func() {
224-
for {
224+
for { //nolint:gosimple
225225
select {
226226
case <-dimTicker.C:
227227
tick_displayDim()
@@ -236,7 +236,7 @@ func startBacklightTickers() {
236236
defer offTicker.Stop()
237237

238238
go func() {
239-
for {
239+
for { //nolint:gosimple
240240
select {
241241
case <-offTicker.C:
242242
tick_displayOff()

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ require (
1515
github.com/gwatts/rootcerts v0.0.0-20240401182218-3ab9db955caf
1616
github.com/hanwen/go-fuse/v2 v2.5.1
1717
github.com/hashicorp/go-envparse v0.1.0
18-
github.com/openstadia/go-usb-gadget v0.0.0-20231115171102-aebd56bbb965
1918
github.com/pion/logging v0.2.2
2019
github.com/pion/mdns/v2 v2.0.7
2120
github.com/pion/webrtc/v4 v4.0.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
8787
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
8888
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
8989
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
90-
github.com/openstadia/go-usb-gadget v0.0.0-20231115171102-aebd56bbb965 h1:bZGtUfkOl0dqvem8ltx9KCYied0gSlRuDhaZDxgppN4=
91-
github.com/openstadia/go-usb-gadget v0.0.0-20231115171102-aebd56bbb965/go.mod h1:6cAIK2c4O3/yETSrRjmNwsBL3yE4Vcu9M9p/Qwx5+gM=
9290
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
9391
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
9492
github.com/pilebones/go-udev v0.9.0 h1:N1uEO/SxUwtIctc0WLU0t69JeBxIYEYnj8lT/Nabl9Q=

jsonrpc.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ func rpcSetEDID(edid string) error {
195195

196196
// Save EDID to config, allowing it to be restored on reboot.
197197
config.EdidString = edid
198-
SaveConfig()
199-
198+
_ = SaveConfig()
200199
return nil
201200
}
202201

@@ -596,18 +595,18 @@ func rpcSetActiveExtension(extensionId string) error {
596595
return nil
597596
}
598597
if config.ActiveExtension == "atx-power" {
599-
unmountATXControl()
598+
_ = unmountATXControl()
600599
} else if config.ActiveExtension == "dc-power" {
601-
unmountDCControl()
600+
_ = unmountDCControl()
602601
}
603602
config.ActiveExtension = extensionId
604603
if err := SaveConfig(); err != nil {
605604
return fmt.Errorf("failed to save config: %w", err)
606605
}
607606
if extensionId == "atx-power" {
608-
mountATXControl()
607+
_ = mountATXControl()
609608
} else if extensionId == "dc-power" {
610-
mountDCControl()
609+
_ = mountDCControl()
611610
}
612611
return nil
613612
}
@@ -728,7 +727,7 @@ func rpcSetSerialSettings(settings SerialSettings) error {
728727
Parity: parity,
729728
}
730729

731-
port.SetMode(serialPortMode)
730+
_ = port.SetMode(serialPortMode)
732731

733732
return nil
734733
}

network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func checkNetworkState() {
107107
if newState != networkState {
108108
logger.Info("network state changed")
109109
// restart MDNS
110-
startMDNS()
110+
_ = startMDNS()
111111
networkState = newState
112112
requestDisplayUpdate()
113113
}

ntp.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const (
2020
)
2121

2222
var (
23-
timeSynced = false
2423
timeSyncRetryInterval = 0 * time.Second
2524
defaultNTPServers = []string{
2625
"time.cloudflare.com",
@@ -58,7 +57,6 @@ func TimeSyncLoop() {
5857
continue
5958
}
6059
logger.Infof("Time sync successful, now is: %v, time taken: %v", time.Now(), time.Since(start))
61-
timeSynced = true
6260
time.Sleep(timeSyncInterval) // after the first sync is done
6361
}
6462
}

serial.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ const serialPortPath = "/dev/ttyS3"
1616
var port serial.Port
1717

1818
func mountATXControl() error {
19-
port.SetMode(defaultMode)
19+
_ = port.SetMode(defaultMode)
2020
go runATXControl()
2121

2222
return nil
2323
}
2424

2525
func unmountATXControl() error {
26-
reopenSerialPort()
26+
_ = reopenSerialPort()
2727
return nil
2828
}
2929

@@ -122,13 +122,13 @@ func pressATXResetButton(duration time.Duration) error {
122122
}
123123

124124
func mountDCControl() error {
125-
port.SetMode(defaultMode)
125+
_ = port.SetMode(defaultMode)
126126
go runDCControl()
127127
return nil
128128
}
129129

130130
func unmountDCControl() error {
131-
reopenSerialPort()
131+
_ = reopenSerialPort()
132132
return nil
133133
}
134134

@@ -212,11 +212,11 @@ var defaultMode = &serial.Mode{
212212
}
213213

214214
func initSerialPort() {
215-
reopenSerialPort()
215+
_ = reopenSerialPort()
216216
if config.ActiveExtension == "atx-power" {
217-
mountATXControl()
217+
_ = mountATXControl()
218218
} else if config.ActiveExtension == "dc-power" {
219-
mountDCControl()
219+
_ = mountDCControl()
220220
}
221221
}
222222

0 commit comments

Comments
 (0)