Skip to content

Commit

Permalink
Fix lint errors.
Browse files Browse the repository at this point in the history
Signed-off-by: zhanluxianshen <irelandabby883@gmail.com>
  • Loading branch information
zhanluxianshen authored and MandssS committed Jul 1, 2024
1 parent 662e04e commit cdaf85f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions channel/local_unixs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ package channel
import (
"context"
"fmt"
"github.com/chaosblade-io/chaosblade-spec-go/log"
"os"
"os/exec"
"strconv"
"strings"
"time"

"github.com/chaosblade-io/chaosblade-spec-go/log"

"github.com/chaosblade-io/chaosblade-spec-go/spec"
"github.com/chaosblade-io/chaosblade-spec-go/util"
"github.com/shirou/gopsutil/process"
Expand Down Expand Up @@ -69,7 +70,7 @@ func (l *LocalChannel) GetPidsByProcessCmdName(processName string, ctx context.C
for _, p := range processes {
name, err := p.Name()
if err != nil {
log.Debugf(ctx, "get process name error, pid: %s, err: %v", p.Pid, err)
log.Debugf(ctx, "get process name error, pid: %v, err: %v", p.Pid, err)
continue
}
if processName != name {
Expand Down Expand Up @@ -133,7 +134,7 @@ func (l *LocalChannel) GetPidsByProcessName(processName string, ctx context.Cont
}
cmdline, err := p.Cmdline()
if err != nil {
log.Debugf(ctx, "get command line error, pid: %s, err: %v", p.Pid, err)
log.Debugf(ctx, "get command line error, pid: %v, err: %v", p.Pid, err)
continue
}
if !strings.Contains(cmdline, processName) {
Expand Down Expand Up @@ -233,7 +234,7 @@ func (l *LocalChannel) GetPidUser(pid string) (string, error) {
}

func (l *LocalChannel) GetPidsByLocalPorts(ctx context.Context, localPorts []string) ([]string, error) {
if localPorts == nil || len(localPorts) == 0 {
if len(localPorts) == 0 {
return nil, fmt.Errorf("the local port parameter is empty")
}
var result = make([]string, 0)
Expand All @@ -243,7 +244,7 @@ func (l *LocalChannel) GetPidsByLocalPorts(ctx context.Context, localPorts []str
return nil, fmt.Errorf("failed to get pid by %s, %v", port, err)
}
log.Infof(ctx, "get pids by %s port returns %v", port, pids)
if pids != nil && len(pids) > 0 {
if len(pids) > 0 {
result = append(result, pids...)
}
}
Expand Down

0 comments on commit cdaf85f

Please sign in to comment.