Browse Source

map is unordered in go

aeris 5 months ago
parent
commit
dc63f1df01
2 changed files with 4 additions and 2 deletions
  1. 3
    1
      identity.go
  2. 1
    1
      main.go

+ 3
- 1
identity.go View File

@@ -53,7 +53,9 @@ func findIdentityName(config Config, prog string, args []string) string {
53 53
 	}
54 54
 	identities := config.Identities
55 55
 	host := extractHost(prog, args)
56
-	for match, name := range identities {
56
+	for _, identity := range identities {
57
+		match := identity.Key.(string)
58
+		name := identity.Value.(string)
57 59
 		if strings.Contains(host, match) {
58 60
 			return name
59 61
 		}

+ 1
- 1
main.go View File

@@ -15,7 +15,7 @@ type Config struct {
15 15
 	AgentsDir       string
16 16
 	IdentitiesDir   string
17 17
 	DefaultIdentity string `yaml:"default_identity"`
18
-	Identities      map[string]string
18
+	Identities      yaml.MapSlice
19 19
 }
20 20
 
21 21
 var sshOptions = map[string]map[string]string{

Loading…
Cancel
Save