mirror of
https://github.com/simon987/ws_bucket.git
synced 2025-04-19 02:06:46 +00:00
Create readme
This commit is contained in:
parent
fea86af41d
commit
04f2ff8900
15
README.md
Normal file
15
README.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
### Environment variables
|
||||||
|
|
||||||
|
| Name | Default |
|
||||||
|
|:---|:---|
|
||||||
|
| `WS_BUCKET_ADDR` | `0.0.0.0:3020` |
|
||||||
|
| `WS_BUCKET_WORKDIR` | `./data` |
|
||||||
|
| `WS_BUCKET_LOGLEVEL` | `trace` |
|
||||||
|
| `WS_BUCKET_CONNSTR` | `host=localhost user=ws_bucket dbname=ws_bucket password=ws_bucket sslmode=disable` |
|
||||||
|
| `WS_BUCKET_DIALECT` | `postgres` |
|
||||||
|
|
||||||
|
### Running tests
|
||||||
|
```bash
|
||||||
|
cd test/
|
||||||
|
go test
|
||||||
|
```
|
21
main.go
21
main.go
@ -3,11 +3,12 @@ package main
|
|||||||
import (
|
import (
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
"github.com/simon987/ws_bucket/api"
|
"github.com/simon987/ws_bucket/api"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -15,3 +16,21 @@ func main() {
|
|||||||
a := api.New(db)
|
a := api.New(db)
|
||||||
a.Run()
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user