~yerinalexey/gobin

7626ff7cc8c182be92ce4a2d1ce9e14fe8e43f40 — Alexey Yerin 5 months ago deec3dc
config: rename dbUri to databaseUri
4 files changed, 6 insertions(+), 6 deletions(-)

M README.md
M config.example.toml
M config/config.go
M main.go
M README.md => README.md +1 -1
@@ 28,7 28,7 @@ go build
DATABASE_URI=postgres://.. ./gobin-migrate up
```

`DATABASE_URI` is the same as `dbUri` in `config.toml`.
`DATABASE_URI` is the same as `databaseUri` in `config.toml`.

If something goes wrong, you can apply migrations manually by running
`up.sql` files in subdirectories of `./migrations`.

M config.example.toml => config.example.toml +1 -1
@@ 3,7 3,7 @@
# Postgres database URI to connect to
#
# Format as follows: postgres://<USER>[:PASSWORD]@<HOST>[:PORT]/<DB>
dbUri = "postgres://postgres:qqqq@localhost/gobin"
databaseUri = "postgres://postgres:qqqq@localhost/gobin"

# On which port the application runs
#

M config/config.go => config/config.go +3 -3
@@ 10,7 10,7 @@ import (
)

type Config struct {
	DbUri string
	DatabaseUri string
	Port int

	TemplateRoot string


@@ 33,8 33,8 @@ func New(configFile string) (*Config, error) {
	}

	// Checks to make sure config is not messed up
	if cfg.DbUri == "" {
		return nil, errors.New("DbUri is not set")
	if cfg.DatabaseUri == "" {
		return nil, errors.New("DatabaseUri is not set")
	}

	if cfg.Port == 0 {

M main.go => main.go +1 -1
@@ 42,7 42,7 @@ func main() {
		log.Fatalln("Invalid configuration:", err)
	}

	pool, err := pgxpool.Connect(context.Background(), config.DbUri)
	pool, err := pgxpool.Connect(context.Background(), config.DatabaseUri)
	if err != nil {
		log.Fatalln("Can't connect to the database: ", err)
	}