Change import path and update example in README

This commit is contained in:
akp 2024-06-18 21:52:21 +01:00
parent fe009f63d4
commit 87d326246a
No known key found for this signature in database
GPG key ID: CF8D58F3DEB20755
2 changed files with 9 additions and 8 deletions

View file

@ -4,12 +4,12 @@
--- ---
[![Go Reference](https://pkg.go.dev/badge/git.tdpain.net/pkg/cfger.svg)](https://pkg.go.dev/git.tdpain.net/pkg/cfger) [![Go Reference](https://pkg.go.dev/badge/go.akpain.net/cfger.svg)](https://pkg.go.dev/go.akpain.net/cfger)
## Install ## Install
``` ```
go get git.tdpain.net/pkg/cfger go get go.akpain.net/cfger
``` ```
## Example usage ## Example usage
@ -18,7 +18,8 @@ go get git.tdpain.net/pkg/cfger
package config package config
import ( import (
"git.tdpain.net/pkg/cfger" "cmp"
"go.akpain.net/cfger"
) )
type HTTP struct { type HTTP struct {
@ -43,13 +44,13 @@ func Load() (*Config, error) {
} }
conf := &Config{ conf := &Config{
Debug: cl.Required("debug").AsBool(), Debug: cmp.Or(cl.Get("debug").AsBool(), cl.GetEnv("DEBUG").AsBool()),
HTTP: &HTTP{ HTTP: &HTTP{
Host: cl.WithDefault("http.host", "127.0.0.1").AsString(), Host: cl.Get("http.host").WithDefault("127.0.0.1").AsString(),
Port: cl.WithDefault("http.port", 8080).AsInt(), Port: cl.Get("http.port").WithDefault(8080).AsInt(),
}, },
Database: &Database{ Database: &Database{
DSN: cl.WithDefault("database.dsn", "website.db").AsString(), DSN: cl.Get("database.dsn").Required().AsString(),
}, },
} }

2
go.mod
View file

@ -1,4 +1,4 @@
module git.tdpain.net/pkg/cfger module go.akpain.net/cfger
go 1.18 go 1.18