sandbox: move out of internal
Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
26
sandbox/executable.go
Normal file
26
sandbox/executable.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package sandbox
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
executable string
|
||||
executableOnce sync.Once
|
||||
)
|
||||
|
||||
func copyExecutable() {
|
||||
if name, err := os.Executable(); err != nil {
|
||||
msg.BeforeExit()
|
||||
log.Fatalf("cannot read executable path: %v", err)
|
||||
} else {
|
||||
executable = name
|
||||
}
|
||||
}
|
||||
|
||||
func MustExecutable() string {
|
||||
executableOnce.Do(copyExecutable)
|
||||
return executable
|
||||
}
|
||||
Reference in New Issue
Block a user