From d84e3d4b5370e0e27f782413a1babc707ad30af9 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Mon, 22 Feb 2021 10:07:39 +0800 Subject: [PATCH] fix golint issues in core/proc (#502) --- core/proc/env.go | 2 ++ core/proc/process.go | 2 ++ core/proc/shutdown.go | 5 +++++ core/proc/stopper.go | 1 + 4 files changed, 10 insertions(+) diff --git a/core/proc/env.go b/core/proc/env.go index f33dad04..ca5e4fb4 100644 --- a/core/proc/env.go +++ b/core/proc/env.go @@ -11,6 +11,7 @@ var ( envLock sync.RWMutex ) +// Env returns the value of the given environment variable. func Env(name string) string { envLock.RLock() val, ok := envs[name] @@ -28,6 +29,7 @@ func Env(name string) string { return val } +// EnvInt returns an int value of the given environment variable. func EnvInt(name string) (int, bool) { val := Env(name) if len(val) == 0 { diff --git a/core/proc/process.go b/core/proc/process.go index 15a9eb4c..9622f129 100644 --- a/core/proc/process.go +++ b/core/proc/process.go @@ -15,10 +15,12 @@ func init() { pid = os.Getpid() } +// Pid returns pid of current process. func Pid() int { return pid } +// ProcessName returns the processname, same as the command name. func ProcessName() string { return procName } diff --git a/core/proc/shutdown.go b/core/proc/shutdown.go index a0d1c3da..cb9eee37 100644 --- a/core/proc/shutdown.go +++ b/core/proc/shutdown.go @@ -24,14 +24,19 @@ var ( delayTimeBeforeForceQuit = waitTime ) +// AddShutdownListener adds fn as a shutdown listener. +// The returned func can be used to wait for fn getting called. func AddShutdownListener(fn func()) (waitForCalled func()) { return shutdownListeners.addListener(fn) } +// AddWrapUpListener adds fn as a wrap up listener. +// The returned func can be used to wait for fn getting called. func AddWrapUpListener(fn func()) (waitForCalled func()) { return wrapUpListeners.addListener(fn) } +// SetTimeToForceQuit sets the waiting time before force quitting. func SetTimeToForceQuit(duration time.Duration) { delayTimeBeforeForceQuit = duration } diff --git a/core/proc/stopper.go b/core/proc/stopper.go index 1e05f015..4aaa0cbc 100644 --- a/core/proc/stopper.go +++ b/core/proc/stopper.go @@ -3,6 +3,7 @@ package proc var noopStopper nilStopper type ( + // Stopper interface wraps the method Stop. Stopper interface { Stop() }