forked from gookit/goutil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysutil.go
47 lines (39 loc) · 822 Bytes
/
sysutil.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Package sysutil provide some system util functions. eg: sysenv, exec, user, process
package sysutil
import (
"os"
"path/filepath"
)
// Workdir get
func Workdir() string {
dir, _ := os.Getwd()
return dir
}
// BinDir get
func BinDir() string {
return filepath.Dir(os.Args[0])
}
// BinName get
func BinName() string {
return filepath.Base(os.Args[0])
}
// BinFile get
func BinFile() string {
return os.Args[0]
}
// Open file or url address
func Open(fileOrURL string) error {
return OpenURL(fileOrURL)
}
// OpenBrowser file or url address
func OpenBrowser(fileOrURL string) error {
return OpenURL(fileOrURL)
}
// OpenFile opens new browser window for the file path.
func OpenFile(path string) error {
fpath, err := filepath.Abs(path)
if err != nil {
return err
}
return OpenURL("file://" + fpath)
}