Skip to content

Commit d3641bb

Browse files
committed
Chore: Fix up various linting issues
In prep to add golangci-lint, fix various linting issues. * Make the `kvm` package a fully-qualified public package. Signed-off-by: SuperQ <[email protected]>
1 parent 4884240 commit d3641bb

File tree

9 files changed

+17
-13
lines changed

9 files changed

+17
-13
lines changed

cloud.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func runWebsocketClient() error {
150150
if err != nil {
151151
return err
152152
}
153-
defer c.CloseNow()
153+
defer c.CloseNow() //nolint:errcheck
154154
cloudLogger.Infof("websocket connected to %s", wsURL)
155155
runCtx, cancelRun := context.WithCancel(context.Background())
156156
defer cancelRun()

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package main
22

33
import (
4-
"kvm"
4+
"github.com/jetkvm/kvm"
55
)
66

77
func main() {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module kvm
1+
module github.com/jetkvm/kvm
22

33
go 1.21.0
44

hw.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func extractSerialNumber() (string, error) {
1414
return "", err
1515
}
1616

17-
r, err := regexp.Compile("Serial\\s*:\\s*(\\S+)")
17+
r, err := regexp.Compile(`Serial\s*:\s*(\S+)`)
1818
if err != nil {
1919
return "", fmt.Errorf("failed to compile regex: %w", err)
2020
}
@@ -27,7 +27,7 @@ func extractSerialNumber() (string, error) {
2727
return matches[1], nil
2828
}
2929

30-
func readOtpEntropy() ([]byte, error) {
30+
func readOtpEntropy() ([]byte, error) { //nolint:unused
3131
content, err := os.ReadFile("/sys/bus/nvmem/devices/rockchip-otp0/nvmem")
3232
if err != nil {
3333
return nil, err

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func Main() {
4949
time.Sleep(15 * time.Minute)
5050
for {
5151
logger.Debugf("UPDATING - Auto update enabled: %v", config.AutoUpdateEnabled)
52-
if config.AutoUpdateEnabled == false {
52+
if !config.AutoUpdateEnabled {
5353
return
5454
}
5555
if currentSession != nil {

native.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"syscall"
1414
"time"
1515

16+
"github.com/jetkvm/kvm/resource"
17+
1618
"github.com/pion/webrtc/v4/pkg/media"
1719
)
1820

@@ -90,8 +92,8 @@ func WriteCtrlMessage(message []byte) error {
9092
return err
9193
}
9294

93-
var nativeCtrlSocketListener net.Listener
94-
var nativeVideoSocketListener net.Listener
95+
var nativeCtrlSocketListener net.Listener //nolint:unused
96+
var nativeVideoSocketListener net.Listener //nolint:unused
9597

9698
var ctrlClientConnected = make(chan struct{})
9799

remote_mount.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (w *WebRTCDiskReader) Read(ctx context.Context, offset int64, size int64) (
4949
if err != nil {
5050
return nil, err
5151
}
52-
buf := make([]byte, 0)
52+
var buf []byte
5353
for {
5454
select {
5555
case data := <-diskReadChan:

terminal.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ func handleTerminalChannel(d *webrtc.DataChannel) {
5555
var size TerminalSize
5656
err := json.Unmarshal([]byte(msg.Data), &size)
5757
if err == nil {
58-
pty.Setsize(ptmx, &pty.Winsize{
58+
err = pty.Setsize(ptmx, &pty.Winsize{
5959
Rows: uint16(size.Rows),
6060
Cols: uint16(size.Cols),
6161
})
62-
return
62+
if err == nil {
63+
return
64+
}
6365
}
6466
logger.Errorf("Failed to parse terminal size: %v", err)
6567
}
@@ -74,7 +76,7 @@ func handleTerminalChannel(d *webrtc.DataChannel) {
7476
ptmx.Close()
7577
}
7678
if cmd != nil && cmd.Process != nil {
77-
cmd.Process.Kill()
79+
_ = cmd.Process.Kill()
7880
}
7981
})
8082
}

wol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func createMagicPacket(mac net.HardwareAddr) []byte {
4343

4444
// Write the target MAC address 16 times
4545
for i := 0; i < 16; i++ {
46-
binary.Write(&buf, binary.BigEndian, mac)
46+
_ = binary.Write(&buf, binary.BigEndian, mac)
4747
}
4848

4949
return buf.Bytes()

0 commit comments

Comments
 (0)