config: Add a default json encoder.
This commit is contained in:
@@ -20,6 +20,12 @@ func DecodeJsonConfig(r io.Reader, v interface{}) error {
|
|||||||
return d.Decode(v)
|
return d.Decode(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Simple JSON based configuration encoder.
|
||||||
|
func EncodeJsonConfig(w io.Writer, v interface{}) error {
|
||||||
|
e := json.NewEncoder(w)
|
||||||
|
return e.Encode(v)
|
||||||
|
}
|
||||||
|
|
||||||
// Return a configuration file path. If baseName is empty,
|
// Return a configuration file path. If baseName is empty,
|
||||||
// then the current executable name without the extension
|
// then the current executable name without the extension
|
||||||
// is used. If postfix is empty then DefaultPostfix is used.
|
// is used. If postfix is empty then DefaultPostfix is used.
|
||||||
|
|||||||
Reference in New Issue
Block a user