From a93796494b473707dc2ae62ec5f90b6bb13d3de5 Mon Sep 17 00:00:00 2001 From: TakayukiB Goto Date: Thu, 24 Oct 2019 18:40:27 +0900 Subject: [PATCH] [Process] Define the Groups() only once --- process/process.go | 5 +++++ process/process_darwin.go | 3 --- process/process_fallback.go | 3 --- process/process_freebsd.go | 3 --- process/process_linux.go | 5 ----- process/process_windows.go | 3 --- 6 files changed, 5 insertions(+), 17 deletions(-) diff --git a/process/process.go b/process/process.go index 4148e65..d83a745 100644 --- a/process/process.go +++ b/process/process.go @@ -314,3 +314,8 @@ func (p *Process) CPUPercentWithContext(ctx context.Context) (float64, error) { return math.Min(100, math.Max(0, 100*cput.Total()/totalTime)), nil } + +// Groups returns all group IDs(include supplementary groups) of the process as a slice of the int +func (p *Process) Groups() ([]int32, error) { + return p.GroupsWithContext(context.Background()) +} diff --git a/process/process_darwin.go b/process/process_darwin.go index 24dd8fb..0c53052 100644 --- a/process/process_darwin.go +++ b/process/process_darwin.go @@ -250,9 +250,6 @@ func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) { return gids, nil } -func (p *Process) Groups() ([]int32, error) { - return p.GroupsWithContext(context.Background()) -} func (p *Process) GroupsWithContext(ctx context.Context) ([]int32, error) { k, err := p.getKProc() diff --git a/process/process_fallback.go b/process/process_fallback.go index cf707ed..43803e7 100644 --- a/process/process_fallback.go +++ b/process/process_fallback.go @@ -139,9 +139,6 @@ func (p *Process) Gids() ([]int32, error) { func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) { return []int32{}, common.ErrNotImplementedError } -func (p *Process) Groups() ([]int32, error) { - return p.GroupsWithContext(context.Background()) -} func (p *Process) GroupsWithContext(ctx context.Context) ([]int32, error) { return []int32{}, common.ErrNotImplementedError diff --git a/process/process_freebsd.go b/process/process_freebsd.go index 18e9de9..fb0ba6f 100644 --- a/process/process_freebsd.go +++ b/process/process_freebsd.go @@ -213,9 +213,6 @@ func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) { return gids, nil } -func (p *Process) Groups() ([]int32, error) { - return p.GroupsWithContext(context.Background()) -} func (p *Process) GroupsWithContext(ctx context.Context) ([]int32, error) { k, err := p.getKProc() diff --git a/process/process_linux.go b/process/process_linux.go index b1f4b49..e9b0e52 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -228,11 +228,6 @@ func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) { return p.gids, nil } -// Groups returns groups of the process as a slice of the int -func (p *Process) Groups() ([]int32, error) { - return p.GroupsWithContext(context.Background()) -} - func (p *Process) GroupsWithContext(ctx context.Context) ([]int32, error) { err := p.fillFromStatusWithContext(ctx) if err != nil { diff --git a/process/process_windows.go b/process/process_windows.go index ff318d0..58b70a5 100644 --- a/process/process_windows.go +++ b/process/process_windows.go @@ -408,9 +408,6 @@ func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) { var gids []int32 return gids, common.ErrNotImplementedError } -func (p *Process) Groups() ([]int32, error) { - return p.GroupsWithContext(context.Background()) -} func (p *Process) GroupsWithContext(ctx context.Context) ([]int32, error) { var groups []int32