aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/proc/self.go
blob: 6dc92eb729501ae7f605080988e23ecbd3f6dae8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package proc

import (
	"os"
	"sync"

	"git.gensokyo.uk/security/fortify/internal/fmsg"
)

var (
	executable     string
	executableOnce sync.Once
)

func copyExecutable() {
	if name, err := os.Executable(); err != nil {
		fmsg.Fatalf("cannot read executable path: %v", err)
	} else {
		executable = name
	}
}

func MustExecutable() string {
	executableOnce.Do(copyExecutable)
	return executable
}