Update plugin.go

配置信息保存的时候需要使用os.O_TRUNC 模式, 否则只会覆盖前面的字符
This commit is contained in:
gaoyang
2022-10-10 14:21:26 +08:00
committed by GitHub
parent 9454ded0ee
commit 9e55c1aa8c

View File

@@ -188,7 +188,7 @@ func (opt *Plugin) Save() error {
opt.saveTimer = time.AfterFunc(time.Second, func() {
lock.Lock()
defer lock.Unlock()
file, err := os.OpenFile(opt.settingPath(), os.O_CREATE|os.O_WRONLY, 0644)
file, err := os.OpenFile(opt.settingPath(), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err == nil {
defer file.Close()
err = yaml.NewEncoder(file).Encode(opt.Modified)