Matthew R Kasun 3 years ago
parent
commit
9132089853
1 changed files with 7 additions and 5 deletions
  1. 7 5
      netclient/ncutils/netclientutils.go

+ 7 - 5
netclient/ncutils/netclientutils.go

@@ -450,19 +450,21 @@ func PrintLog(message string, loglevel int) {
 
 // GetSystemNetworks - get networks locally
 func GetSystemNetworks() ([]string, error) {
+	var networks []string
 	files, err := filepath.Glob(GetNetclientPathSpecific() + "netconfig-*")
 	if err != nil {
 		return nil, err
 	}
-	i := 0
 	for _, file := range files {
 		//don't want files such as *.bak, *.swp
-		if filepath.Ext(file) == "" {
-			files[i] = filepath.Base(file)
-			i++
+		if filepath.Ext(file) != "" {
+			continue
 		}
+		file := filepath.Base(file)
+		temp := strings.Split(file, "-")
+		networks = append(networks, temp[1])
 	}
-	return files[:i], nil
+	return networks, nil
 }
 
 func stringAfter(original string, substring string) string {