mirror of https://github.com/jetkvm/kvm.git
Chore: Enable golangci-lint
Add a GitHub actions workflow to run golangci-lint. Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
parent
d3641bb4b9
commit
75296b4b7e
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
name: golangci-lint
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- "go.sum"
|
||||
- "go.mod"
|
||||
- "**.go"
|
||||
- ".github/workflows/golangci-lint.yml"
|
||||
- ".golangci.yml"
|
||||
pull_request:
|
||||
|
||||
permissions: # added using https://github.com/step-security/secure-repo
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
golangci:
|
||||
permissions:
|
||||
contents: read # for actions/checkout to fetch code
|
||||
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
|
||||
name: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
|
||||
with:
|
||||
go-version: 1.23.x
|
||||
- name: Lint
|
||||
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
|
||||
with:
|
||||
args: --verbose
|
||||
version: v1.62.0
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
linters:
|
||||
enable:
|
||||
# - goimports
|
||||
# - misspell
|
||||
# - revive
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: _test.go
|
||||
linters:
|
||||
- errcheck
|
|
@ -211,7 +211,7 @@ func startBacklightTickers() {
|
|||
// Don't start the tickers if the display is switched off.
|
||||
// Set the display to off if that's the case.
|
||||
if config.DisplayMaxBrightness == 0 {
|
||||
setDisplayBrightness(0)
|
||||
_ = setDisplayBrightness(0)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ func startBacklightTickers() {
|
|||
defer dimTicker.Stop()
|
||||
|
||||
go func() {
|
||||
for {
|
||||
for { //nolint:gosimple
|
||||
select {
|
||||
case <-dimTicker.C:
|
||||
tick_displayDim()
|
||||
|
@ -236,7 +236,7 @@ func startBacklightTickers() {
|
|||
defer offTicker.Stop()
|
||||
|
||||
go func() {
|
||||
for {
|
||||
for { //nolint:gosimple
|
||||
select {
|
||||
case <-offTicker.C:
|
||||
tick_displayOff()
|
||||
|
|
1
go.mod
1
go.mod
|
@ -15,7 +15,6 @@ require (
|
|||
github.com/gwatts/rootcerts v0.0.0-20240401182218-3ab9db955caf
|
||||
github.com/hanwen/go-fuse/v2 v2.5.1
|
||||
github.com/hashicorp/go-envparse v0.1.0
|
||||
github.com/openstadia/go-usb-gadget v0.0.0-20231115171102-aebd56bbb965
|
||||
github.com/pion/logging v0.2.2
|
||||
github.com/pion/mdns/v2 v2.0.7
|
||||
github.com/pion/webrtc/v4 v4.0.0
|
||||
|
|
2
go.sum
2
go.sum
|
@ -87,8 +87,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
|||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/openstadia/go-usb-gadget v0.0.0-20231115171102-aebd56bbb965 h1:bZGtUfkOl0dqvem8ltx9KCYied0gSlRuDhaZDxgppN4=
|
||||
github.com/openstadia/go-usb-gadget v0.0.0-20231115171102-aebd56bbb965/go.mod h1:6cAIK2c4O3/yETSrRjmNwsBL3yE4Vcu9M9p/Qwx5+gM=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/pilebones/go-udev v0.9.0 h1:N1uEO/SxUwtIctc0WLU0t69JeBxIYEYnj8lT/Nabl9Q=
|
||||
|
|
13
jsonrpc.go
13
jsonrpc.go
|
@ -195,8 +195,7 @@ func rpcSetEDID(edid string) error {
|
|||
|
||||
// Save EDID to config, allowing it to be restored on reboot.
|
||||
config.EdidString = edid
|
||||
SaveConfig()
|
||||
|
||||
_ = SaveConfig()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -596,18 +595,18 @@ func rpcSetActiveExtension(extensionId string) error {
|
|||
return nil
|
||||
}
|
||||
if config.ActiveExtension == "atx-power" {
|
||||
unmountATXControl()
|
||||
_ = unmountATXControl()
|
||||
} else if config.ActiveExtension == "dc-power" {
|
||||
unmountDCControl()
|
||||
_ = unmountDCControl()
|
||||
}
|
||||
config.ActiveExtension = extensionId
|
||||
if err := SaveConfig(); err != nil {
|
||||
return fmt.Errorf("failed to save config: %w", err)
|
||||
}
|
||||
if extensionId == "atx-power" {
|
||||
mountATXControl()
|
||||
_ = mountATXControl()
|
||||
} else if extensionId == "dc-power" {
|
||||
mountDCControl()
|
||||
_ = mountDCControl()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -728,7 +727,7 @@ func rpcSetSerialSettings(settings SerialSettings) error {
|
|||
Parity: parity,
|
||||
}
|
||||
|
||||
port.SetMode(serialPortMode)
|
||||
_ = port.SetMode(serialPortMode)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ func checkNetworkState() {
|
|||
if newState != networkState {
|
||||
logger.Info("network state changed")
|
||||
// restart MDNS
|
||||
startMDNS()
|
||||
_ = startMDNS()
|
||||
networkState = newState
|
||||
requestDisplayUpdate()
|
||||
}
|
||||
|
|
2
ntp.go
2
ntp.go
|
@ -20,7 +20,6 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
timeSynced = false
|
||||
timeSyncRetryInterval = 0 * time.Second
|
||||
defaultNTPServers = []string{
|
||||
"time.cloudflare.com",
|
||||
|
@ -58,7 +57,6 @@ func TimeSyncLoop() {
|
|||
continue
|
||||
}
|
||||
logger.Infof("Time sync successful, now is: %v, time taken: %v", time.Now(), time.Since(start))
|
||||
timeSynced = true
|
||||
time.Sleep(timeSyncInterval) // after the first sync is done
|
||||
}
|
||||
}
|
||||
|
|
14
serial.go
14
serial.go
|
@ -16,14 +16,14 @@ const serialPortPath = "/dev/ttyS3"
|
|||
var port serial.Port
|
||||
|
||||
func mountATXControl() error {
|
||||
port.SetMode(defaultMode)
|
||||
_ = port.SetMode(defaultMode)
|
||||
go runATXControl()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func unmountATXControl() error {
|
||||
reopenSerialPort()
|
||||
_ = reopenSerialPort()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -122,13 +122,13 @@ func pressATXResetButton(duration time.Duration) error {
|
|||
}
|
||||
|
||||
func mountDCControl() error {
|
||||
port.SetMode(defaultMode)
|
||||
_ = port.SetMode(defaultMode)
|
||||
go runDCControl()
|
||||
return nil
|
||||
}
|
||||
|
||||
func unmountDCControl() error {
|
||||
reopenSerialPort()
|
||||
_ = reopenSerialPort()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -212,11 +212,11 @@ var defaultMode = &serial.Mode{
|
|||
}
|
||||
|
||||
func initSerialPort() {
|
||||
reopenSerialPort()
|
||||
_ = reopenSerialPort()
|
||||
if config.ActiveExtension == "atx-power" {
|
||||
mountATXControl()
|
||||
_ = mountATXControl()
|
||||
} else if config.ActiveExtension == "dc-power" {
|
||||
mountDCControl()
|
||||
_ = mountDCControl()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue