Browse Source

refactor(logger,config): move filename to consts

ayn2op 1 năm trước cách đây
mục cha
commit
09cf630c15
2 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 3 1
      internal/config/config.go
  2. 3 1
      internal/logger/logger.go

+ 3 - 1
internal/config/config.go

@@ -11,6 +11,8 @@ import (
 	"github.com/diamondburned/arikawa/v3/discord"
 )
 
+const fileName = "config.toml"
+
 type Config struct {
 	Mouse  bool   `toml:"mouse"`
 	Editor string `toml:"editor"`
@@ -61,7 +63,7 @@ func Load() (*Config, error) {
 		path = "."
 	}
 
-	path = filepath.Join(path, consts.Name, "config.toml")
+	path = filepath.Join(path, consts.Name, fileName)
 	f, err := os.Open(path)
 
 	cfg := defaultConfig()

+ 3 - 1
internal/logger/logger.go

@@ -8,6 +8,8 @@ import (
 	"github.com/ayn2op/discordo/internal/consts"
 )
 
+const fileName = "logs.txt"
+
 // Opens the log file and configures default logger.
 func Load() error {
 	path, err := os.UserCacheDir()
@@ -20,7 +22,7 @@ func Load() error {
 		return err
 	}
 
-	path = filepath.Join(path, "logs.txt")
+	path = filepath.Join(path, fileName)
 	file, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, os.ModePerm)
 	if err != nil {
 		return err