2025-02-16 17:26:09 +09:00
|
|
|
package internal
|
2025-01-18 11:59:33 +09:00
|
|
|
|
|
|
|
import (
|
2025-02-16 17:26:09 +09:00
|
|
|
"log"
|
2025-01-18 11:59:33 +09:00
|
|
|
"os"
|
|
|
|
"sync"
|
2025-02-16 19:02:52 +09:00
|
|
|
|
|
|
|
"git.gensokyo.uk/security/fortify/internal/fmsg"
|
2025-01-18 11:59:33 +09:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
executable string
|
|
|
|
executableOnce sync.Once
|
|
|
|
)
|
|
|
|
|
|
|
|
func copyExecutable() {
|
|
|
|
if name, err := os.Executable(); err != nil {
|
2025-02-16 19:02:52 +09:00
|
|
|
fmsg.BeforeExit()
|
2025-02-16 17:26:09 +09:00
|
|
|
log.Fatalf("cannot read executable path: %v", err)
|
2025-01-18 11:59:33 +09:00
|
|
|
} else {
|
|
|
|
executable = name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func MustExecutable() string {
|
|
|
|
executableOnce.Do(copyExecutable)
|
|
|
|
return executable
|
|
|
|
}
|