From 80be12d0d51e1bf6a9debd1c69b0da9ebbb28254 Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Sat, 23 Nov 2024 15:23:20 +0500 Subject: [PATCH 1/2] docs(config): add method description --- util/config.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/config.go b/util/config.go index e0970940..f57c1c39 100644 --- a/util/config.go +++ b/util/config.go @@ -731,11 +731,17 @@ func (d *DbConfig) GetConnectionString(includeDbName bool) (connectionString str return } +// PrintDbInfo prints the database connection information based on the current configuration. +// It retrieves the database dialect and prints the corresponding connection details. +// If the dialect is not found, it panics with an error message. func (conf *ConfigType) PrintDbInfo() { + // Get the database dialect dialect, err := conf.GetDialect() if err != nil { panic(err) } + + // Print database connection information based on the dialect switch dialect { case DbDriverMySQL: fmt.Printf("MySQL %v@%v %v\n", conf.MySQL.GetUsername(), conf.MySQL.GetHostname(), conf.MySQL.GetDbName()) From b18fb8dced25f5ffc5c7103f9eb943e806d905cc Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Sat, 23 Nov 2024 15:27:25 +0500 Subject: [PATCH 2/2] docs(config): add method docs --- util/config.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/util/config.go b/util/config.go index f57c1c39..b21e1437 100644 --- a/util/config.go +++ b/util/config.go @@ -677,6 +677,16 @@ func (d *DbConfig) GetHostname() string { return d.Hostname } +// GetConnectionString constructs the database connection string based on the current configuration. +// It supports MySQL, BoltDB, and PostgreSQL dialects. +// If the dialect is unsupported, it returns an error. +// +// Parameters: +// - includeDbName: a boolean indicating whether to include the database name in the connection string. +// +// Returns: +// - connectionString: the constructed database connection string. +// - err: an error if the dialect is unsupported. func (d *DbConfig) GetConnectionString(includeDbName bool) (connectionString string, err error) { dbName := d.GetDbName() dbUser := d.GetUsername()