ssh_config
ssh_config copied to clipboard
Since unable to set spaceBeforeComment, EOLComment is printed without any leading space in generated config
When generate a config, there is no way to set spaceBeforeComment, which cause the # and EOLComment is printed immediately after the pattern. We have to downgrade to v1.1.0.
Can you say in a bit more detail? You want to generate a file that looks like
Host foo # comment
But you can only generate a file now that looks like
Host foo # comment
Is that right?
No, the line will be generated as: Host foo# comment
Example:
package main
import (
"fmt"
"github.com/kevinburke/ssh_config"
)
func main() {
nodes := []ssh_config.Node{
&ssh_config.KV{Key: " Hostname", Value: "1.2.3.4"},
&ssh_config.KV{Key: " Port", Value: "22"},
&ssh_config.KV{Key: " User", Value: "user"},
&ssh_config.KV{Key: " NumberOfPasswordPrompts", Value: "1"},
}
pattern, err := ssh_config.NewPattern("example")
if err != nil {
return
}
host := &ssh_config.Host{
Patterns: []*ssh_config.Pattern{pattern},
Nodes: nodes,
}
host.EOLComment = "my comment"
config := ssh_config.Config{
Hosts: []*ssh_config.Host{host},
}
content, err := config.MarshalText()
if err != nil {
return
}
fmt.Println(string(content))
}
Output:
Host example#my comment
Hostname 1.2.3.4
Port 22
User user
NumberOfPasswordPrompts 1