You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
855 B
Go
48 lines
855 B
Go
1 year ago
|
// Package nsys provide some system util functions. eg: sysenv, exec, user, process
|
||
|
package nsys
|
||
|
|
||
|
import (
|
||
|
"git.noahlan.cn/noahlan/ntool/internal/common"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
)
|
||
|
|
||
|
// Workdir get
|
||
|
func Workdir() string {
|
||
|
return common.Workdir()
|
||
|
}
|
||
|
|
||
|
// 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)
|
||
|
}
|