diff options
| author | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-09-20 10:35:50 +0300 |
|---|---|---|
| committer | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-09-20 10:35:50 +0300 |
| commit | 6ced549deaecb42b9bb93ea9efcb4c1bbaabe8a4 (patch) | |
| tree | 28d8d82530476cf607e4d05ca189ae05868711e6 /config/config.go | |
| parent | f60682a6b7cb749fee403c84e2587c3ad7e7ced0 (diff) | |
docs: add comments for all functions
Diffstat (limited to 'config/config.go')
| -rw-r--r-- | config/config.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go index d5fe65ff..c9a3e83c 100644 --- a/config/config.go +++ b/config/config.go @@ -1,3 +1,5 @@ +// Package config provides configuration management utilities for the 3x-ui panel, +// including version information, logging levels, database paths, and environment variable handling. package config import ( @@ -16,8 +18,10 @@ var version string //go:embed name var name string +// LogLevel represents the logging level for the application. type LogLevel string +// Logging level constants const ( Debug LogLevel = "debug" Info LogLevel = "info" @@ -26,14 +30,17 @@ const ( Error LogLevel = "error" ) +// GetVersion returns the version string of the 3x-ui application. func GetVersion() string { return strings.TrimSpace(version) } +// GetName returns the name of the 3x-ui application. func GetName() string { return strings.TrimSpace(name) } +// GetLogLevel returns the current logging level based on environment variables or defaults to Info. func GetLogLevel() LogLevel { if IsDebug() { return Debug @@ -45,10 +52,12 @@ func GetLogLevel() LogLevel { return LogLevel(logLevel) } +// IsDebug returns true if debug mode is enabled via the XUI_DEBUG environment variable. func IsDebug() bool { return os.Getenv("XUI_DEBUG") == "true" } +// GetBinFolderPath returns the path to the binary folder, defaulting to "bin" if not set via XUI_BIN_FOLDER. func GetBinFolderPath() string { binFolderPath := os.Getenv("XUI_BIN_FOLDER") if binFolderPath == "" { @@ -74,6 +83,7 @@ func getBaseDir() string { return exeDir } +// GetDBFolderPath returns the path to the database folder based on environment variables or platform defaults. func GetDBFolderPath() string { dbFolderPath := os.Getenv("XUI_DB_FOLDER") if dbFolderPath != "" { @@ -85,10 +95,12 @@ func GetDBFolderPath() string { return "/etc/x-ui" } +// GetDBPath returns the full path to the database file. func GetDBPath() string { return fmt.Sprintf("%s/%s.db", GetDBFolderPath(), GetName()) } +// GetLogFolder returns the path to the log folder based on environment variables or platform defaults. func GetLogFolder() string { logFolderPath := os.Getenv("XUI_LOG_FOLDER") if logFolderPath != "" { |
