47 lines
650 B
Go
47 lines
650 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime/debug"
|
|
)
|
|
|
|
var (
|
|
Executable string
|
|
Root string
|
|
Library string
|
|
WorkingDirectory string
|
|
)
|
|
|
|
func init() {
|
|
debug.SetGCPercent(-1)
|
|
Reset()
|
|
|
|
var err error
|
|
Executable, err = os.Executable()
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
Executable, err = filepath.EvalSymlinks(Executable)
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
WorkingDirectory, err = os.Getwd()
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
Root = filepath.Dir(Executable)
|
|
Library = filepath.Join(Root, "lib")
|
|
stat, err := os.Stat(Library)
|
|
|
|
if os.IsNotExist(err) || stat == nil || !stat.IsDir() {
|
|
findLibrary()
|
|
}
|
|
}
|