mirror of
https://github.com/simon987/ws_bucket.git
synced 2025-12-19 01:29:04 +00:00
Create readme
This commit is contained in:
21
main.go
21
main.go
@@ -3,11 +3,12 @@ package main
|
||||
import (
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/simon987/ws_bucket/api"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
db, err := gorm.Open("postgres", "host=localhost user=ws_bucket dbname=ws_bucket password=ws_bucket sslmode=disable")
|
||||
db, err := gorm.Open(getDialect(), getConnStr())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -15,3 +16,21 @@ func main() {
|
||||
a := api.New(db)
|
||||
a.Run()
|
||||
}
|
||||
|
||||
func getConnStr() string {
|
||||
connStr := os.Getenv("WS_BUCKET_CONNSTR")
|
||||
if connStr == "" {
|
||||
return "host=localhost user=ws_bucket dbname=ws_bucket password=ws_bucket sslmode=disable"
|
||||
} else {
|
||||
return connStr
|
||||
}
|
||||
}
|
||||
|
||||
func getDialect() string {
|
||||
connStr := os.Getenv("WS_BUCKET_DIALECT")
|
||||
if connStr == "" {
|
||||
return "postgres"
|
||||
} else {
|
||||
return connStr
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user