Skip to content

Commit

Permalink
chore: update example_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
aranw committed May 23, 2024
1 parent 8569863 commit 9fa6781
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion example_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package yamlcfg_test

import (
"embed"
"log/slog"

"github.com/aranw/yamlcfg"
Expand All @@ -10,7 +11,7 @@ type Config struct {
LogLevel string `yaml:"log_level"`
}

func ExampleLoad() {
func ExampleParse() {
cfg, err := yamlcfg.Parse[Config]("config.yaml")
if err != nil {
slog.Error("loading yaml config", "err", err)
Expand All @@ -19,3 +20,16 @@ func ExampleLoad() {

_ = cfg.LogLevel
}

//go:embed testdata
var testdata embed.FS

func ExampleParseFS() {
cfg, err := yamlcfg.ParseFS[Config](testdata, "config.yaml")
if err != nil {
slog.Error("loading yaml config", "err", err)
return
}

_ = cfg.LogLevel
}

0 comments on commit 9fa6781

Please sign in to comment.