mirror of
https://github.com/wavetermdev/ssh_config.git
synced 2026-08-05 13:43:40 -07:00
Implement encoding.TextMarshaler interface
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/bazel-*
|
||||
@@ -274,12 +274,20 @@ func (c *Config) Get(alias, key string) (string, error) {
|
||||
}
|
||||
|
||||
// String returns a string representation of the Config file.
|
||||
func (c *Config) String() string {
|
||||
func (c Config) String() string {
|
||||
return marshal(c).String()
|
||||
}
|
||||
|
||||
func (c Config) MarshalText() ([]byte, error) {
|
||||
return marshal(c).Bytes(), nil
|
||||
}
|
||||
|
||||
func marshal(c Config) *bytes.Buffer {
|
||||
var buf bytes.Buffer
|
||||
for i := range c.Hosts {
|
||||
buf.WriteString(c.Hosts[i].String())
|
||||
}
|
||||
return buf.String()
|
||||
return &buf
|
||||
}
|
||||
|
||||
// Pattern is a pattern in a Host declaration. Patterns are read-only values;
|
||||
|
||||
Reference in New Issue
Block a user