MCPcopy Create free account
hub / github.com/creasty/defaults / ExampleSetter

Function ExampleSetter

example_test.go:73–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71}
72
73func ExampleSetter() {
74 var config Config
75 if err := defaults.Set(&config); err != nil {
76 panic(err)
77 }
78 fmt.Println(config.Retries, config.Backoff)
79
80 // A value the caller supplied is left alone.
81 custom := Config{Backoff: time.Minute}
82 if err := defaults.Set(&custom); err != nil {
83 panic(err)
84 }
85 fmt.Println(custom.Retries, custom.Backoff)
86 // Output:
87 // 3 3s
88 // 3 1m0s
89}
90
91func ExampleCanUpdate() {
92 fmt.Println(defaults.CanUpdate(0), defaults.CanUpdate(123))

Callers

nothing calls this directly

Calls 1

SetFunction · 0.92

Tested by

no test coverage detected