diff options
| author | Shulhan <m.shulhan@gmail.com> | 2020-04-25 06:31:12 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2020-04-25 06:39:55 +0700 |
| commit | 9295f006bdfdcc2b73c667447ff1e62508018cef (patch) | |
| tree | 4f8a2b9a2a3f1ef8795bdebc3f218a01c84cab76 /lib/ssh | |
| parent | 9736ede5f0a7b40bb659b39356e6d8ccb9c78ac3 (diff) | |
| download | pakakeh.go-9295f006bdfdcc2b73c667447ff1e62508018cef.tar.xz | |
ssh: add method to Prepend the other Section
This function can be useful if we want to load another SSH config file
without using Include directive.
Diffstat (limited to 'lib/ssh')
| -rw-r--r-- | lib/ssh/config.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/ssh/config.go b/lib/ssh/config.go index 13773586..e3f4c930 100644 --- a/lib/ssh/config.go +++ b/lib/ssh/config.go @@ -266,6 +266,21 @@ func (cfg *Config) Get(s string) (section *ConfigSection) { return nil } +// +// Prepend other Config's sections to this Config. +// The other's sections will be at the top of the list. +// +// This function can be useful if we want to load another SSH config file +// without using Include directive. +// +func (cfg *Config) Prepend(other *Config) { + newSections := make([]*ConfigSection, 0, + len(cfg.sections)+len(other.sections)) + newSections = append(newSections, other.sections...) + newSections = append(newSections, cfg.sections...) + cfg.sections = newSections +} + func parseBool(key, val string) (out bool, err error) { switch val { case valueNo: |
