diff --git a/fig.go b/fig.go index 31ecbbb..eb00349 100644 --- a/fig.go +++ b/fig.go @@ -28,12 +28,13 @@ const ( DefaultTimeLayout = time.RFC3339 ) -// StringUnmarshaler is an interface for custom unmarshaling of strings +// StringUnmarshaler is an interface designed for custom string unmarshaling. // -// If a field with a local type asignment satisfies this interface, it allows the user -// to implement their own custom type unmarshaling method. +// This interface is used when a field of a custom type needs to define its own +// method for unmarshaling from a string. This is particularly useful for handling +// different string representations that need to be converted into a specific type. // -// Example: +// Example usage: // // type ListenerType uint // @@ -43,10 +44,6 @@ const ( // ListenerTLS // ) // -// type Config struct { -// Listener ListenerType `fig:"listener_type" default:"unix"` -// } -// // func (l *ListenerType) UnmarshalType(v string) error { // switch strings.ToLower(v) { // case "unix": @@ -60,6 +57,10 @@ const ( // } // return nil // } +// +// type Config struct { +// Listener ListenerType `fig:"listener_type" default:"tcp"` +// } type StringUnmarshaler interface { UnmarshalString(s string) error }