fix golint issues in core/proc (#502)
This commit is contained in:
@@ -11,6 +11,7 @@ var (
|
|||||||
envLock sync.RWMutex
|
envLock sync.RWMutex
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Env returns the value of the given environment variable.
|
||||||
func Env(name string) string {
|
func Env(name string) string {
|
||||||
envLock.RLock()
|
envLock.RLock()
|
||||||
val, ok := envs[name]
|
val, ok := envs[name]
|
||||||
@@ -28,6 +29,7 @@ func Env(name string) string {
|
|||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnvInt returns an int value of the given environment variable.
|
||||||
func EnvInt(name string) (int, bool) {
|
func EnvInt(name string) (int, bool) {
|
||||||
val := Env(name)
|
val := Env(name)
|
||||||
if len(val) == 0 {
|
if len(val) == 0 {
|
||||||
|
|||||||
@@ -15,10 +15,12 @@ func init() {
|
|||||||
pid = os.Getpid()
|
pid = os.Getpid()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pid returns pid of current process.
|
||||||
func Pid() int {
|
func Pid() int {
|
||||||
return pid
|
return pid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ProcessName returns the processname, same as the command name.
|
||||||
func ProcessName() string {
|
func ProcessName() string {
|
||||||
return procName
|
return procName
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,14 +24,19 @@ var (
|
|||||||
delayTimeBeforeForceQuit = waitTime
|
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()) {
|
func AddShutdownListener(fn func()) (waitForCalled func()) {
|
||||||
return shutdownListeners.addListener(fn)
|
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()) {
|
func AddWrapUpListener(fn func()) (waitForCalled func()) {
|
||||||
return wrapUpListeners.addListener(fn)
|
return wrapUpListeners.addListener(fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetTimeToForceQuit sets the waiting time before force quitting.
|
||||||
func SetTimeToForceQuit(duration time.Duration) {
|
func SetTimeToForceQuit(duration time.Duration) {
|
||||||
delayTimeBeforeForceQuit = duration
|
delayTimeBeforeForceQuit = duration
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package proc
|
|||||||
var noopStopper nilStopper
|
var noopStopper nilStopper
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
// Stopper interface wraps the method Stop.
|
||||||
Stopper interface {
|
Stopper interface {
|
||||||
Stop()
|
Stop()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user