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

@ -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()