package log import ( "fmt" "os" "path/filepath" ) // getExeFilename func getExeFilename() string { _, logfilename := filepath.Split(os.Args[0]) if logfilename == "" { panic("get exe filename failed") } return logfilename } // tryOptLogDirs func tryOptLogDirs(optLogDirs []string) (string, error) { optionDirsStr := "" for i, d := range optLogDirs { dir := fmt.Sprintf("%s/", d) optionDirsStr += fmt.Sprintf("%d.[%s];", i, dir) if _, err := os.Stat(dir); err == nil { return dir, nil } } return "", fmt.Errorf("all optional dir are not exist: %s", optionDirsStr) }