files.go 297 B

123456789101112131415161718
  1. package sys
  2. import (
  3. "os"
  4. "os/exec"
  5. "path/filepath"
  6. "strings"
  7. )
  8. // GetCurrentDir get current process directory
  9. func GetCurrentDir() string {
  10. file, _ := exec.LookPath(os.Args[0])
  11. path, _ := filepath.Abs(file)
  12. idx := strings.LastIndex(path, string(os.PathSeparator))
  13. return path[:idx]
  14. }