本文整理匯總了Golang中bitbucket/org/kardianos/osext.ExecutableFolder函數的典型用法代碼示例。如果您正苦於以下問題:Golang ExecutableFolder函數的具體用法?Golang ExecutableFolder怎麽用?Golang ExecutableFolder使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ExecutableFolder函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Parse
func Parse() error {
// Change working dir to that of the executable
exeFolder, _ := osext.ExecutableFolder()
os.Chdir(exeFolder)
f := flagconfig.New("gobin")
f.StrParam("loglevel", "logging level (DEBUG, INFO, WARN, ERROR, FATAL)", "DEBUG")
f.StrParam("logfile", "path to log file", "")
f.StrParam("htmltemplates", "path to html templates file", filepath.Join("templates", "htmlTemplates.tmpl"))
f.StrParam("texttemplates", "path to text templates file", filepath.Join("templates", "textTemplates.tmpl"))
f.StrParam("staticpath", "path to static files folder", "static")
f.IntParam("uidlength", "length of gob uid string", 4)
f.IntParam("tokenlength", "length of the secure token string", 15)
f.RequiredStrParam("storetype", "the data store to use")
f.RequiredStrParam("storeconf", "a string of the form 'IP:PORT' to configure the data store")
f.RequiredStrParam("domain", "the domain to use to for links")
f.RequiredStrParam("pygmentizepath", "path to the pygmentize binary")
f.RequiredStrParam("listen", "a string of the form 'IP:PORT' which program will listen on")
f.FlagParam("V", "show version/build information", false)
if err := f.Parse(); err != nil {
return err
}
fcLock.Lock()
defer fcLock.Unlock()
fc = f
//UIDLen = 4
//StoreType = "REDIS"
//Domain = "gobin.io"
//Port = "6667"
return nil
}
示例2: DefaultAssetPath
func DefaultAssetPath() string {
var base string
// If the current working directory is the go-ethereum dir
// assume a debug build and use the source directory as
// asset directory.
pwd, _ := os.Getwd()
if pwd == path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "ethereal") {
base = path.Join(pwd, "assets")
} else {
switch runtime.GOOS {
case "darwin":
// Get Binary Directory
exedir, _ := osext.ExecutableFolder()
base = filepath.Join(exedir, "../Resources")
case "linux":
base = "/usr/share/ethereal"
case "window":
fallthrough
default:
base = "."
}
}
return base
}
示例3: exeFolder
func exeFolder() string {
exeFolder, err := osext.ExecutableFolder()
if err != nil {
panic(err)
}
return exeFolder
}
示例4: GetLogsDirForMe
func GetLogsDirForMe() (string, error) {
processImageDir, err := osext.ExecutableFolder()
if err != nil {
return "", err
}
return filepath.Join(processImageDir, "logs"), nil
}
示例5: Start
func (p *program) Start(s service.Service) error {
runtime.GOMAXPROCS(runtime.NumCPU())
p.exit = make(chan struct{})
var err error
p.execDir, err = osext.ExecutableFolder()
if err != nil {
return err
}
err = p.loadOrWriteConifg()
if err != nil {
return err
}
l, err := net.Listen("tcp", config.ListenOn)
if err != nil {
return err
}
p.listener = l
if filepath.IsAbs(config.CacheFolder) {
p.cacheDir = config.CacheFolder
} else {
p.cacheDir = filepath.Join(p.execDir, config.CacheFolder)
}
err = p.loadTemplate()
if err != nil {
return err
}
// Start should not block. Do the actual work async.
logger.Infof("Starting. Listen to %s", config.ListenOn)
go p.run(l)
return nil
}
示例6: getExeFilePath
func getExeFilePath() (path string) {
var err error
if path, err = osext.ExecutableFolder(); err != nil {
path = ""
}
return
}
示例7: SaveToFile
func (conf *Configuration) SaveToFile(file string) error {
if conf == nil {
return errors.New("I need valid Configuration to save!")
}
var filename string
var err error
conf.Lock()
defer conf.Unlock()
if file == "" {
if conf.filepath != "" {
filename = conf.filepath
} else {
var path string
path, err = osext.ExecutableFolder() //current bin directory
if err == nil {
filename = filepath.Join(path, "config.json")
} else {
filename = "config.json"
}
}
} else if !filepath.IsAbs(file) {
var path string
path, err = osext.ExecutableFolder() //current bin directory
if err == nil {
filename = filepath.Join(path, file)
} else {
filename = file
}
}
if filename != "" {
var cbuf []byte
cbuf, err = json.MarshalIndent(conf, "", " ")
if err == nil {
err = ioutil.WriteFile(filename, cbuf, 0644)
}
}
if err != nil {
return errors.New("Cannot save config file! " + err.Error())
}
return nil
}
示例8: main
func main() {
path, _ := osext.ExecutableFolder()
os.Chdir(path)
go func() {
log.Println(http.ListenAndServe(goCfgMgr.Get("basic", "Host").(string)+":10022", nil))
}()
DoomAnalysis.Start()
}
示例9: CwdToMe
func CwdToMe() error {
exeDir, err := osext.ExecutableFolder()
if err != nil {
return err
}
err = os.Chdir(exeDir)
if err != nil {
return err
}
return nil
}
示例10: ResourcePath
func ResourcePath() (string, error) {
if len(*resource_path) > 0 {
return *resource_path, nil
}
executablePath, err := osext.ExecutableFolder()
if err != nil {
return "", err
}
return filepath.Join(executablePath, "..", "src", "github.com", "EricBurnett", "WebCmd"), nil
}
示例11: resolveSqlRoot
// Resolve the path to our SQL scripts
func resolveSqlRoot(sqlroot string, playbookPath string) (string, error) {
switch sqlroot {
case SQLROOT_BINARY:
return osext.ExecutableFolder()
case SQLROOT_PLAYBOOK:
return filepath.Abs(filepath.Dir(playbookPath))
default:
return sqlroot, nil
}
}
示例12: qmlPrefix
// The qmlPrefix function returns an executable-related path of dir with qml files.
func qmlPrefix() (path string, err error) {
path, err = osext.ExecutableFolder()
if err != nil {
return
}
switch runtime.GOOS {
case "darwin":
return filepath.Join(path, "..", "Resources", "qml"), nil
default:
return filepath.Join(path, "qml"), nil
}
}
示例13: resourceDir
// find the directory containing the lush resource files. looks for a
// "templates" directory in the directory of the executable. if not found try
// to look for them in GOPATH ($GOPATH/src/github.com/....). Panics if no
// resources are found.
func resourceDir() string {
root, err := osext.ExecutableFolder()
if err == nil {
if _, err = os.Stat(root + "/templates"); err == nil {
return root
}
}
// didn't find <dir of executable>/templates
p, err := build.Default.Import(basePkg, "", build.FindOnly)
if err != nil {
panic("Couldn't find lush resource files")
}
return p.Dir
}
示例14: init
func init() {
path, err := osext.ExecutableFolder()
database, err = new(level.Database).SetOptions(
new(level.Options).SetCreateIfMissing(
true,
).SetCacheSize(
500 * level.Megabyte,
),
).OpenDB(path + "/leveldb/")
if err != nil {
log.Fatal("Error binding database: ", err)
}
}
示例15: readConfig
func readConfig() *Cfg {
// note: log will not be configured to write to file yet,
// so who knows who'll see the log output at this stage...
file, e := ioutil.ReadFile("./config.json")
if e != nil {
log.Fatalf("Unable to read config.json: %s", e)
}
var cfg Cfg
json.Unmarshal(file, &cfg)
if cfg.ManagerPath == "" {
log.Fatalf("Strange config: %v", cfg)
}
if cfg.ListenPort <= 0 {
cfg.ListenPort = 8080
}
if cfg.LandlordPort <= 0 {
cfg.LandlordPort = 6380
}
if cfg.TenantPortBase <= 0 {
cfg.TenantPortBase = 6381
}
if cfg.MaxTenants <= 0 {
cfg.MaxTenants = 10
}
if cfg.LogPath == "" {
cfg.LogPath =
func() string {
f, e := osext.ExecutableFolder()
if e != nil {
log.Fatal("Unable to read executable path, add LogPath to config.json.", e)
}
return f + "srv.log"
}()
}
return &cfg
}