Rename "cfg" package to "config", always use "cfg" for variable names

This commit is contained in:
2025-12-27 12:11:10 -05:00
parent 422ca0295a
commit 571bc0a3bd
13 changed files with 57 additions and 58 deletions
+4 -4
View File
@@ -5,10 +5,10 @@ package global
import "github.com/rwinkhart/go-boilerplate/back"
var (
EntryRoot = back.Home + "/.local/share/libmutton" // Path to libmutton entry directory
ConfigDir = back.Home + "/.config/libmutton" // Path to libmutton configuration directory
ConfigPath = ConfigDir + "/libmuttoncfg.json" // Path to libmutton configuration file
AgeDir = ConfigDir + "/age" // Path to libmutton password age directory
EntryRoot = back.Home + "/.local/share/libmutton" // Path to libmutton entry directory
CfgDir = back.Home + "/.config/libmutton" // Path to libmutton configuration directory
CfgPath = CfgDir + "/libmuttoncfg.json" // Path to libmutton configuration file
AgeDir = CfgDir + "/age" // Path to libmutton password age directory
)
const (
+4 -4
View File
@@ -5,10 +5,10 @@ package global
import "github.com/rwinkhart/go-boilerplate/back"
var (
EntryRoot = back.Home + "\\AppData\\Local\\libmutton\\entries" // Path to libmutton entry directory
ConfigDir = back.Home + "\\AppData\\Local\\libmutton\\config" // Path to libmutton configuration directory
ConfigPath = ConfigDir + "\\libmuttoncfg.json" // Path to libmutton configuration file
AgeDir = ConfigDir + "\\age" // Path to libmutton password age directory
EntryRoot = back.Home + "\\AppData\\Local\\libmutton\\entries" // Path to libmutton entry directory
CfgDir = back.Home + "\\AppData\\Local\\libmutton\\config" // Path to libmutton configuration directory
CfgPath = CfgDir + "\\libmuttoncfg.json" // Path to libmutton configuration file
AgeDir = CfgDir + "\\age" // Path to libmutton password age directory
)
const (
+1 -1
View File
@@ -26,7 +26,7 @@ func GetCurrentDeviceID() (string, error) {
// Requires: errorOnFail (set to true to throw an error if the devices directory cannot be read/does not exist)
func GenDeviceIDList() ([]fs.DirEntry, error) {
// create a slice of all registered devices
deviceIDList, err := os.ReadDir(ConfigDir + PathSeparator + "devices")
deviceIDList, err := os.ReadDir(CfgDir + PathSeparator + "devices")
if err != nil {
return nil, errors.New("unable to read devices directory: " + err.Error())
}
+6 -6
View File
@@ -9,7 +9,7 @@ import (
// DirInit creates the libmutton directories.
// Returns: oldDeviceID (from before the directory reset; will be FSMisc if there is no pre-existing ID).
func DirInit(preserveOldConfigDir bool) (string, error) {
func DirInit(preserveOldCfgDir bool) (string, error) {
// create EntryRoot
err := os.MkdirAll(EntryRoot, 0700)
if err != nil {
@@ -23,10 +23,10 @@ func DirInit(preserveOldConfigDir bool) (string, error) {
}
// remove existing config directory (if it exists and not in append mode)
if !preserveOldConfigDir {
isAccessible, _ := back.TargetIsFile(ConfigDir, false) // error is ignored because dir/file status is irrelevant
if !preserveOldCfgDir {
isAccessible, _ := back.TargetIsFile(CfgDir, false) // error is ignored because dir/file status is irrelevant
if isAccessible {
err = os.RemoveAll(ConfigDir)
err = os.RemoveAll(CfgDir)
if err != nil {
return "", errors.New("unable to remove existing config directory: " + err.Error())
}
@@ -34,9 +34,9 @@ func DirInit(preserveOldConfigDir bool) (string, error) {
}
// create config directory w/devices subdirectory
err = os.MkdirAll(ConfigDir+PathSeparator+"devices", 0700)
err = os.MkdirAll(CfgDir+PathSeparator+"devices", 0700)
if err != nil {
return "", errors.New("unable to create \"" + ConfigDir + "\": " + err.Error())
return "", errors.New("unable to create \"" + CfgDir + "\": " + err.Error())
}
// create password age directory