| 1 | package ssh_config_testscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config_test`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/" |
| 5 | "path/filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/" |
| 6 | "stringsscip-go gomod github.com/golang/go/src go1.18 strings/" |
| 7 | |
| 8 | "github.com/dimonomid/ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/" |
| 9 | ) |
| 10 | |
| 11 | func ExampleHost_Matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config_test`/ExampleHost_Matches().() { |
| 12 | pat, _ := ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/.NewPatternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/NewPattern().("test.*.example.com") |
| 13 | host := &ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/.Hostscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#{Patternsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Patterns.: []*ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/.Patternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#{pat}} |
| 14 | fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Printlnscip-go gomod github.com/golang/go/src go1.18 fmt/Println().(host.Matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Matches().("test.stage.example.com")) |
| 15 | fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Printlnscip-go gomod github.com/golang/go/src go1.18 fmt/Println().(host.Matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Matches().("othersubdomain.example.com")) |
| 16 | // Output: |
| 17 | // true |
| 18 | // false |
| 19 | } |
| 20 | |
| 21 | func ExamplePatternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config_test`/ExamplePattern().() { |
| 22 | pat, _ := ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/.NewPatternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/NewPattern().("*") |
| 23 | host := &ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/.Hostscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#{Patternsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Patterns.: []*ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/.Patternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#{pat}} |
| 24 | fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Printlnscip-go gomod github.com/golang/go/src go1.18 fmt/Println().(host.Matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Matches().("test.stage.example.com")) |
| 25 | fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Printlnscip-go gomod github.com/golang/go/src go1.18 fmt/Println().(host.Matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Matches().("othersubdomain.any.any")) |
| 26 | // Output: |
| 27 | // true |
| 28 | // true |
| 29 | } |
| 30 | |
| 31 | func ExampleDecodescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config_test`/ExampleDecode().() { |
| 32 | var config = ` |
| 33 | Host *.example.com |
| 34 | Compression yes |
| 35 | ` |
| 36 | |
| 37 | cfg, _ := ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/.Decodescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Decode().(stringsscip-go gomod github.com/golang/go/src go1.18 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.18 strings/NewReader().(config), false) |
| 38 | val, _ := cfg.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#Get().("test.example.com", "Compression") |
| 39 | fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Printlnscip-go gomod github.com/golang/go/src go1.18 fmt/Println().(val) |
| 40 | // Output: yes |
| 41 | } |
| 42 | |
| 43 | func ExampleDefaultscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config_test`/ExampleDefault().() { |
| 44 | fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Printlnscip-go gomod github.com/golang/go/src go1.18 fmt/Println().(ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/.Defaultscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Default().("Port")) |
| 45 | fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Printlnscip-go gomod github.com/golang/go/src go1.18 fmt/Println().(ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/.Defaultscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Default().("UnknownVar")) |
| 46 | // Output: |
| 47 | // 22 |
| 48 | // |
| 49 | } |
| 50 | |
| 51 | func ExampleUserSettings_ConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config_test`/ExampleUserSettings_ConfigFinder().() { |
| 52 | // This can be used to test SSH config parsing. |
| 53 | u := ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/.UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{} |
| 54 | u.ConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#ConfigFinder().(func() string { |
| 55 | return filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/Join().("testdata", "test_config") |
| 56 | }, |
| 57 | ) |
| 58 | u.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("example.com", "Host") |
| 59 | } |