Fix linting issues (#595)

* fix lint

* Bump golangci-lint action to v8 and update linting args

* fix lint errors

* fix: correct loop condition in main function to process remaining arguments
This commit is contained in:
Boshi Lian 2025-05-18 00:59:18 -07:00 committed by GitHub
parent 22ad31b127
commit 2c2d378f86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 17 additions and 17 deletions

View file

@ -33,9 +33,9 @@ jobs:
run: go test -v -race -cover -tags full ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
args: --timeout=60m -E gofmt --verbose --print-resources-usage --build-tags full
args: --timeout=60m --verbose --print-resources-usage --build-tags full -D errcheck
env:
GOGC: "10"

View file

@ -60,7 +60,8 @@ func newAsciicastLogger(recorddir string, prefix string) *asciicastLogger {
}
func (l *asciicastLogger) uphook(msg []byte) error {
if msg[0] == msgChannelData {
switch msg[0] {
case msgChannelData:
clientChannelID := binary.BigEndian.Uint32(msg[1:5])
f, ok := l.channels[clientChannelID]
@ -74,7 +75,7 @@ func (l *asciicastLogger) uphook(msg []byte) error {
return err
}
}
} else if msg[0] == msgChannelOpenConfirm {
case msgChannelOpenConfirm:
clientChannelID := binary.BigEndian.Uint32(msg[1:5])
serverChannelID := binary.BigEndian.Uint32(msg[5:9])
l.channelIDMap[serverChannelID] = clientChannelID

View file

@ -244,7 +244,9 @@ func (d *daemon) run() error {
log.Errorf("cannot create screen recording dir %v: %v", recorddir, err)
return
}
if d.recordfmt == "asciicast" {
switch d.recordfmt {
case "asciicast":
prefix := ""
if d.usernameAsRecorddir {
// add prefix to avoid conflict
@ -255,7 +257,7 @@ func (d *daemon) run() error {
uphookchain.append(ssh.InspectPacketHook(recorder.uphook))
downhookchain.append(ssh.InspectPacketHook(recorder.downhook))
} else if d.recordfmt == "typescript" {
case "typescript":
recorder, err := newFilePtyLogger(recorddir)
if err != nil {
log.Errorf("cannot create screen recording logger: %v", err)

View file

@ -346,7 +346,7 @@ func (g *GrpcPlugin) createUpstream(conn ssh.ConnMetadata, challengeCtx ssh.Chal
caCertificate, ok := caPublicKey.(*ssh.Certificate)
if !ok {
return nil, fmt.Errorf("Failed to convert the caPublicKey to an ssh.Certificate")
return nil, fmt.Errorf("failed to convert the caPublicKey to an ssh.Certificate")
}
private, err = ssh.NewCertSigner(caCertificate, private)

View file

@ -260,10 +260,7 @@ func main() {
args := ctx.Args().Slice()
remain := args
for {
if len(remain) <= 0 {
break
}
for len(remain) > 0 {
args, remain = splitByDash(remain)

View file

@ -30,7 +30,7 @@ func newFilePtyLogger(outputdir string) (*filePtyLogger, error) {
return nil, err
}
_, err = typescript.Write([]byte(fmt.Sprintf("Script started on %v\n", now.Format(time.ANSIC))))
_, err = fmt.Fprintf(typescript, "Script started on %v\n", now.Format(time.ANSIC))
if err != nil {
return nil, err
@ -79,7 +79,7 @@ func (l *filePtyLogger) Close() (err error) {
// if _, err = ; err != nil {
// return err
// }
_, _ = l.typescript.Write([]byte(fmt.Sprintf("Script done on %v\n", time.Now().Format(time.ANSIC))))
_, _ = fmt.Fprintf(l.typescript, "Script done on %v\n", time.Now().Format(time.ANSIC))
l.typescript.Close()
l.timing.Close()

View file

@ -73,7 +73,7 @@ func TestOldSshd(t *testing.T) {
enterPassword(stdin, stdout, "pass")
waitForStdoutContains(stdout, "SSHREADY", func(_ string) {
_, _ = stdin.Write([]byte(fmt.Sprintf("%v\n", "triggerping")))
_, _ = fmt.Fprintf(stdin, "%v\n", "triggerping")
})
time.Sleep(time.Second * 3) // wait for file flush

View file

@ -108,7 +108,7 @@ func waitForStdoutContains(stdout io.Reader, text string, cb func(string)) {
func enterPassword(stdin io.Writer, stdout io.Reader, password string) {
waitForStdoutContains(stdout, "'s password", func(_ string) {
_, _ = stdin.Write([]byte(fmt.Sprintf("%v\n", password)))
_, _ = fmt.Fprintf(stdin, "%v\n", password)
log.Printf("got password prompt, sending password")
})
}

View file

@ -18,7 +18,7 @@ func (l *singleConnListener) Accept() (net.Conn, error) {
// Addr implements net.Listener
func (l *singleConnListener) Addr() net.Addr {
return l.conn.LocalAddr()
return l.LocalAddr()
}
// Close implements net.Listener

View file

@ -67,7 +67,7 @@ func (l *listOrString) UnmarshalYAML(value *yaml.Node) error {
l.Str = str
return nil
}
return fmt.Errorf("Failed to unmarshal OneOfType")
return fmt.Errorf("failed to unmarshal OneOfType")
}
type yamlPipe struct {