12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package common
- import (
- "os"
- "path/filepath"
- "runtime"
- )
- func GetRunPath() string {
- var path string
- if path = GetInstallPath(); !FileExists(path) {
- return "./"
- }
- return path
- }
- func GetInstallPath() string {
- var path string
- if IsWindows() {
- path = `C:\Program Files\nps`
- } else {
- path = "/etc/nps"
- }
- return path
- }
- func GetAppPath() string {
- if path, err := filepath.Abs(filepath.Dir(os.Args[0])); err == nil {
- return path
- }
- return os.Args[0]
- }
- func IsWindows() bool {
- if runtime.GOOS == "windows" {
- return true
- }
- return false
- }
- func GetLogPath() string {
- var path string
- if IsWindows() {
- path = "./"
- } else {
- path = "/tmp"
- }
- return path
- }
- func GetTmpPath() string {
- var path string
- if IsWindows() {
- path = GetRunPath()
- } else {
- path = "/tmp"
- }
- return path
- }
|