All checks were successful
Test / Create distribution (push) Successful in 31s
Test / Sandbox (push) Successful in 1m55s
Test / Hakurei (push) Successful in 2m47s
Test / Sandbox (race detector) (push) Successful in 3m16s
Test / Planterette (push) Successful in 3m32s
Test / Hakurei (race detector) (push) Successful in 4m25s
Test / Flake checks (push) Successful in 1m9s
Signed-off-by: Ophestra <cat@gensokyo.uk>
27 lines
374 B
Go
27 lines
374 B
Go
package hakurei
|
|
|
|
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
|
|
}
|