From 5f84eb243bed58db1bfe8906a9c60671ee555960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9=20=D0=A2?= =?UTF-8?q?=D1=83=D1=85=D1=82=D0=B0=D1=80=D0=BE=D0=B2?= Date: Tue, 25 Jul 2023 06:36:41 +0500 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20EN?= =?UTF-8?q?V=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fiber/init.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fiber/init.go b/fiber/init.go index f64cae1..f2ac67d 100644 --- a/fiber/init.go +++ b/fiber/init.go @@ -21,14 +21,18 @@ type App struct { db *sqlx.DB } + type StringHandler func(db *sqlx.DB, query string) string type HTMLHandler func(db *sqlx.DB, query string) map[string]interface{} func OpenDB(database string) *sqlx.DB { // fmt.Printf("открываю БД nano-svelte\n") - db, err := sqlx.Open("mysql", "itman:X753951x@(xigmanas:3306)/"+database) + username := os.Getenv("USERNAMEDB") + password := os.Getenv("PASSWORDDB") + connstr := fmt.Sprintf("%s:%s@(xigmanas:3306)/%s", username, password, database) + db, err := sqlx.Open("mysql", connstr) if err != nil { - fmt.Errorf("невозможно открыть базу данных %s", database) + fmt.Errorf("невозможно открыть базу данных %s, %v\n", database, err) os.Exit(0) } return db