Skip to content

Commit e1b1dcd

Browse files
Fix review comments for PR microsoft#630
- Rename variables to follow Go naming conventions: - out_s -> outStr - got_name -> gotName - instdict -> instanceDict - Add argument validation to serverlistCommand
1 parent a1cbf57 commit e1b1dcd

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

pkg/sqlcmd/commands.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@ func xmlCommand(s *Sqlcmd, args []string, line uint) error {
602602
}
603603

604604
func serverlistCommand(s *Sqlcmd, args []string, line uint) error {
605+
if len(args) > 0 && args[0] != "" {
606+
return InvalidCommandError("SERVERLIST", line)
607+
}
605608
ListLocalServers(s.GetOutput())
606609
return nil
607610
}

pkg/sqlcmd/serverlist.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,26 @@ func GetLocalServerInstances() []string {
6565
func parseInstances(msg []byte) msdsn.BrowserData {
6666
results := msdsn.BrowserData{}
6767
if len(msg) > 3 && msg[0] == 5 {
68-
out_s := string(msg[3:])
69-
tokens := strings.Split(out_s, ";")
70-
instdict := map[string]string{}
71-
got_name := false
68+
outStr := string(msg[3:])
69+
tokens := strings.Split(outStr, ";")
70+
instanceDict := map[string]string{}
71+
gotName := false
7272
var name string
7373
for _, token := range tokens {
74-
if got_name {
75-
instdict[name] = token
76-
got_name = false
74+
if gotName {
75+
instanceDict[name] = token
76+
gotName = false
7777
} else {
7878
name = token
7979
if len(name) == 0 {
80-
if len(instdict) == 0 {
80+
if len(instanceDict) == 0 {
8181
break
8282
}
83-
results[strings.ToUpper(instdict["InstanceName"])] = instdict
84-
instdict = map[string]string{}
83+
results[strings.ToUpper(instanceDict["InstanceName"])] = instanceDict
84+
instanceDict = map[string]string{}
8585
continue
8686
}
87-
got_name = true
87+
gotName = true
8888
}
8989
}
9090
}

0 commit comments

Comments
 (0)