Skip to content

Commit

Permalink
Merge pull request #8 from fumeapp/feat/db-port
Browse files Browse the repository at this point in the history
Define DB Port
  • Loading branch information
acidjazz authored Dec 21, 2023
2 parents b900173 + 3412c03 commit 5fdeaf0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"context"
"crypto/tls"
"fmt"
"log"
"net/http"

awsconfig "github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/fumeapp/tonic/setting"
Expand All @@ -12,19 +15,18 @@ import (
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"log"
"net/http"
)

var Db *gorm.DB
var Os *opensearch.Client

func DSN() string {
return fmt.Sprintf(
"%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local",
"%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local",
setting.Database.Username,
setting.Database.Password,
setting.Database.Host,
setting.Database.Port,
setting.Database.Database,
)
}
Expand Down
2 changes: 2 additions & 0 deletions setting/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package setting
type DatabaseSetting struct {
Connect string
Host string
Port string
Database string
Username string
Password string
Expand All @@ -17,6 +18,7 @@ func DatabaseSetup() *DatabaseSetting {
Database.Connect = env("DB_CONNECT", "false")
Database.Logging = env("DB_LOGGING", "false")
Database.Host = env("DB_HOST", "localhost")
Database.Port = env("DB_PORT", "3306")
Database.Database = env("DB_DATABASE", "tonic")
Database.Username = env("DB_USERNAME", "root")
Database.Password = env("DB_PASSWORD", "")
Expand Down

0 comments on commit 5fdeaf0

Please sign in to comment.