1 Star 0 Fork 0

leonxiong/xtool

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
util_nowindows.go 355 Bytes
一键复制 编辑 原始数据 按行查看 历史
leonxiong 提交于 2024-12-10 12:22 +08:00 . fixed linux compile error
//go:build !windows
package xfile
import (
"os"
"syscall"
)
func CreateLockFile(filename string) (*os.File, error) {
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
return nil, err
}
err = syscall.Flock(int(file.Fd()), syscall.LOCK_EX|syscall.LOCK_NB)
if err != nil {
return nil, err
}
return file, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xlm516/xtool.git
git@gitee.com:xlm516/xtool.git
xlm516
xtool
xtool
7db4253cb67d

搜索帮助