Skip to content

Commit

Permalink
add example for structconf.Parse
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinfalting committed May 10, 2024
1 parent 3e8c8d8 commit 24d18c6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions structconf_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package structconf_test

import (
"context"
"fmt"
"log"
"os"

"github.com/kevinfalting/structconf"
)

func ExampleParse() {
os.Setenv("NAME", "Vikki")

type Config struct {
Name string `conf:"env:NAME"`
}

var cfg Config

if err := structconf.Parse(context.Background(), &cfg); err != nil {
log.Println("failed to Parse:", err)
}

fmt.Printf("%+v\n", cfg)

// Output:
// {Name:Vikki}
}

0 comments on commit 24d18c6

Please sign in to comment.