simple example for config setting via .env
This commit is contained in:
parent
1f45c625e9
commit
9e73d5f69e
5 changed files with 18 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
bin*
|
||||
.env
|
||||
*.log
|
||||
*.sqlite
|
||||
|
|
|
@ -16,6 +16,7 @@ func Config() lib.Config {
|
|||
Home: ovr(".", HOME),
|
||||
Logging: &logging.Cfg{
|
||||
Logfile: ovr("log/scopes.log", LOGFILE),
|
||||
Level: ovr("info", LOGLEVEL),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -25,6 +26,7 @@ func Config() lib.Config {
|
|||
// collect here the names of fields that may be overridden via
|
||||
// explicit Override() or SCOPES_* environment settings.
|
||||
const (
|
||||
HOME = "home"
|
||||
LOGFILE = "logfile"
|
||||
HOME = "home"
|
||||
LOGFILE = "logfile"
|
||||
LOGLEVEL = "loglevel"
|
||||
)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
module demo
|
||||
|
||||
go 1.20
|
||||
go 1.21
|
||||
|
||||
toolchain go1.21.0
|
||||
|
||||
require git.sr.ht/~cco/go-scopes v0.1.20
|
||||
|
||||
|
|
6
examples/demo/rundemo.sh
Executable file
6
examples/demo/rundemo.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
set -a
|
||||
source .env
|
||||
echo "log level: $SCOPES_LOGLEVEL"
|
||||
|
||||
bin/demo
|
||||
|
|
@ -82,6 +82,9 @@ type module map[string]citem
|
|||
|
||||
func (m module) Compile(f forge.FE) forge.FPtr {
|
||||
v := voc.NewVoc(f.Voc())
|
||||
for key, val := range m {
|
||||
v.Register(key, val)
|
||||
}
|
||||
return f.Code(v)
|
||||
}
|
||||
|
||||
|
@ -102,7 +105,7 @@ type record struct {
|
|||
}
|
||||
|
||||
func (r *record) Compile(f forge.FE) forge.FPtr {
|
||||
return nil
|
||||
return f.Code(r)
|
||||
}
|
||||
|
||||
func (r *record) Data() interface{} {
|
||||
|
|
Loading…
Add table
Reference in a new issue