MCPcopy
hub / github.com/spf13/viper / marshalWriter

Method marshalWriter

viper.go:1735–1754  ·  view source on GitHub ↗

Marshal a map into Writer.

(w io.Writer, configType string)

Source from the content-addressed store, hash-verified

1733
1734// Marshal a map into Writer.
1735func (v *Viper) marshalWriter(w io.Writer, configType string) error {
1736 c := v.AllSettings()
1737
1738 encoder, err := v.encoderRegistry.Encoder(configType)
1739 if err != nil {
1740 return ConfigMarshalError{err}
1741 }
1742
1743 b, err := encoder.Encode(c)
1744 if err != nil {
1745 return ConfigMarshalError{err}
1746 }
1747
1748 _, err = w.Write(b)
1749 if err != nil {
1750 return ConfigMarshalError{err}
1751 }
1752
1753 return nil
1754}
1755
1756func keyExists(k string, m map[string]any) string {
1757 lk := strings.ToLower(k)

Callers 2

WriteConfigToMethod · 0.95
writeConfigMethod · 0.95

Calls 3

AllSettingsMethod · 0.95
EncoderMethod · 0.65
EncodeMethod · 0.65

Tested by

no test coverage detected