diff --git a/process/process_linux.go b/process/process_linux.go index ead99adaa..de742fbde 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -351,7 +351,7 @@ func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, e func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) { pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid) if err != nil { - if pids == nil || len(pids) == 0 { + if len(pids) == 0 { return nil, ErrorNoChildren } return nil, err @@ -705,10 +705,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error return "", err } ret := strings.FieldsFunc(string(cmdline), func(r rune) bool { - if r == '\u0000' { - return true - } - return false + return r == '\u0000' }) return strings.Join(ret, " "), nil diff --git a/process/process_test.go b/process/process_test.go index 8c59b1add..d0c5dc7d3 100644 --- a/process/process_test.go +++ b/process/process_test.go @@ -418,14 +418,14 @@ func Test_Process_Exe(t *testing.T) { func Test_Process_CpuPercent(t *testing.T) { p := testGetProcess() - percent, err := p.Percent(0) + _, err := p.Percent(0) skipIfNotImplementedErr(t, err) if err != nil { t.Errorf("error %v", err) } duration := time.Duration(1000) * time.Microsecond time.Sleep(duration) - percent, err = p.Percent(0) + percent, err := p.Percent(0) if err != nil { t.Errorf("error %v", err) } diff --git a/v3/process/process_linux.go b/v3/process/process_linux.go index 90f61e9c6..a424e0033 100644 --- a/v3/process/process_linux.go +++ b/v3/process/process_linux.go @@ -351,7 +351,7 @@ func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, e func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) { pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid) if err != nil { - if pids == nil || len(pids) == 0 { + if len(pids) == 0 { return nil, ErrorNoChildren } return nil, err @@ -678,10 +678,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error return "", err } ret := strings.FieldsFunc(string(cmdline), func(r rune) bool { - if r == '\u0000' { - return true - } - return false + return r == '\u0000' }) return strings.Join(ret, " "), nil diff --git a/v3/process/process_test.go b/v3/process/process_test.go index 14238e7b3..df31b028f 100644 --- a/v3/process/process_test.go +++ b/v3/process/process_test.go @@ -420,14 +420,14 @@ func Test_Process_Exe(t *testing.T) { func Test_Process_CpuPercent(t *testing.T) { p := testGetProcess() - percent, err := p.Percent(0) + _, err := p.Percent(0) skipIfNotImplementedErr(t, err) if err != nil { t.Errorf("error %v", err) } duration := time.Duration(1000) * time.Microsecond time.Sleep(duration) - percent, err = p.Percent(0) + percent, err := p.Percent(0) if err != nil { t.Errorf("error %v", err) }