1 Star 3 Fork 1

古丞秋/uymas

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
os.go 982 Bytes
一键复制 编辑 原始数据 按行查看 历史
古丞秋 提交于 2021-07-13 09:41 +08:00 . trys: move source github to gitee
package fs
import (
"errors"
"gitee.com/conero/uymas/str"
"os"
"strings"
)
// @Date: 2018/11/7 0007 11:27
// @Author: Joshua Conero
// @Name: 操作系统相关的数据读写
const (
VEnvPath = "path"
)
// EnvPath get os env path list
func EnvPath() []string {
var value []string
path := os.Getenv(VEnvPath)
if path != "" {
value = strings.Split(path, ";")
}
return value
}
// AddEnvPath and path to env
func AddEnvPath(paths ...string) error {
refPath := EnvPath()
addMk := false
for _, path := range paths {
if str.InQuei(path, refPath) == -1 {
refPath = append(refPath, path)
addMk = true
}
}
if addMk {
err := os.Setenv(VEnvPath, strings.Join(refPath, ";"))
// [TIP] 仅仅在当前进程中/实例中有效
// fmt.Println(os.Getenv(V_EnvPath))
return err
}
return errors.New("输入为空或者环境变量已经存在")
}
// DelEnvPath del the path from env path list.
func DelEnvPath(paths ...string) error {
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/conero/uymas.git
git@gitee.com:conero/uymas.git
conero
uymas
uymas
v1.4.2

搜索帮助