1 Star 0 Fork 0

yjhi/go

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
builder.go 748 Bytes
一键复制 编辑 原始数据 按行查看 历史
yjhi 提交于 2024-03-07 20:43 +08:00 . v1.1.7
package jservice
import (
"fmt"
"path"
"runtime"
"strings"
)
func New(file string, params string) (IService, error) {
systemType := runtime.GOOS
rawExeFile := file
exeFile := strings.Replace(rawExeFile, "\\", "/", -1)
exeDir := path.Dir(exeFile)
exeName := path.Base(exeFile)
exeName = strings.Replace(exeName, ".exe", "", 1)
if systemType == "windows" {
return &WinService{
BaseService{
ExeFile: exeFile,
ExeName: exeName,
ExePath: exeDir,
Params: params,
},
}, nil
} else if systemType == "linux" {
return &LinuxService{
BaseService{
ExeFile: exeFile,
ExeName: exeName,
ExePath: exeDir,
Params: params,
},
}, nil
} else {
return nil, fmt.Errorf("System Not Support")
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/yjhi/go.git
git@gitee.com:yjhi/go.git
yjhi
go
go
0475c4b9204b

搜索帮助