10 var registeredInitializers = make(map[string]func())
12 // Register adds an initialization func under the specified name
13 func Register(name string, initializer func()) {
14 if _, exists := registeredInitializers[name]; exists {
15 panic(fmt.Sprintf("reexec func already registered under name %q", name))
18 registeredInitializers[name] = initializer
21 // Init is called as the first part of the exec process and returns true if an
22 // initialization function was called.
24 initializer, exists := registeredInitializers[os.Args[0]]
33 func naiveSelf() string {
35 if filepath.Base(name) == name {
36 if lp, err := exec.LookPath(name); err == nil {
40 // handle conversion of relative paths to absolute
41 if absName, err := filepath.Abs(name); err == nil {
44 // if we couldn't get absolute name, return original
45 // (NOTE: Go only errors on Abs() if os.Getwd fails)