浏览代码

Defer-close the newly created config file (if does not exist)

ayntgl 4 年之前
父节点
当前提交
7d2dd4652f
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      util/config.go

+ 3 - 0
util/config.go

@@ -45,6 +45,7 @@ func LoadConfig() *Config {
 		if err != nil {
 			panic(err)
 		}
+		defer f.Close()
 
 		c := Config{
 			Mouse:         true,
@@ -80,6 +81,8 @@ func LoadConfig() *Config {
 		}
 
 		f.Sync()
+
+		return &c
 	}
 
 	d, err := os.ReadFile(configPath)