From 265df78488e04e3b7e506c878042f8f35750e39d Mon Sep 17 00:00:00 2001 From: Glib Smaga Date: Thu, 5 Oct 2023 08:16:52 -0700 Subject: [PATCH] Remove named returns Named returns should only be used with naked returns, or a deferred function. And in general are better avoided --- agent/agent.go | 4 ++-- goprocess/goprocess.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index c35702d5..02f5da68 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -75,7 +75,7 @@ type Options struct { // Note: The agent exposes an endpoint via a TCP connection that can be used by // any program on the system. Review your security requirements before starting // the agent. -func Listen(opts Options) (err error) { +func Listen(opts Options) error { mu.Lock() defer mu.Unlock() @@ -135,7 +135,7 @@ func listen(l net.Listener) { } } -func saveConfig(opts Options, port int) (err error) { +func saveConfig(opts Options, port int) error { gopsdir := opts.ConfigDir if gopsdir == "" { cfgDir, err := internal.ConfigDir() diff --git a/goprocess/goprocess.go b/goprocess/goprocess.go index dd7eecf1..bf9fa54a 100644 --- a/goprocess/goprocess.go +++ b/goprocess/goprocess.go @@ -94,7 +94,7 @@ func findAll(pss []*process.Process, isGo isGoFunc, concurrencyLimit int) []P { } // Find finds info about the process identified with the given PID. -func Find(pid int) (p P, ok bool, err error) { +func Find(pid int) (P, bool, error) { pr, err := process.NewProcess(int32(pid)) if err != nil { return P{}, false, err