Initialize AutoLibrary website with Gitea deployment
This commit is contained in:
commit
18216953e7
101 files changed
+12581
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func GetRootPath() string {
|
||||
// Production binaries resolve files beside the executable; development
|
||||
// commands resolve the current project, including go run's temp binary.
|
||||
working, _ := os.Getwd()
|
||||
executable, _ := os.Executable()
|
||||
for _, directory := range []string{filepath.Dir(executable), working} {
|
||||
if directory == "" {
|
||||
continue
|
||||
}
|
||||
for _, marker := range []string{"config.json", "frontend", "go.mod"} {
|
||||
if _, err := os.Stat(filepath.Join(directory, marker)); err == nil {
|
||||
return directory
|
||||
}
|
||||
}
|
||||
}
|
||||
if working != "" {
|
||||
return working
|
||||
}
|
||||
return filepath.Dir(executable)
|
||||
}
|
||||
Reference in new issue
Block a user