|
|
@ -60,7 +60,7 @@ func ReadHosts(fn string) (Hosts, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sline := string(bline)
|
|
|
|
sline := string(bline)
|
|
|
|
sline = strings.Trim(sline, " ")
|
|
|
|
sline = strings.TrimSpace(sline)
|
|
|
|
|
|
|
|
|
|
|
|
/* empty line */
|
|
|
|
/* empty line */
|
|
|
|
if sline == "" {
|
|
|
|
if sline == "" {
|
|
|
@ -72,12 +72,9 @@ func ReadHosts(fn string) (Hosts, error) {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* replace tab to space */
|
|
|
|
lns := strings.Fields(sline)
|
|
|
|
sline = strings.Replace(sline, "\t", " ", -1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lns := strings.Split(sline, " ")
|
|
|
|
if len(lns) < 2 {
|
|
|
|
|
|
|
|
|
|
|
|
if len(lns) < 1 {
|
|
|
|
|
|
|
|
return nil, errors.New(fmt.Sprintf("invalid hosts line: %s", sline))
|
|
|
|
return nil, errors.New(fmt.Sprintf("invalid hosts line: %s", sline))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -94,7 +91,7 @@ func ReadHosts(fn string) (Hosts, error) {
|
|
|
|
|
|
|
|
|
|
|
|
for _, dn := range lns[1:] {
|
|
|
|
for _, dn := range lns[1:] {
|
|
|
|
|
|
|
|
|
|
|
|
dd := dns.Fqdn(strings.Trim(dn, " "))
|
|
|
|
dd := dns.Fqdn(strings.TrimSpace(dn))
|
|
|
|
|
|
|
|
|
|
|
|
/* ignore space */
|
|
|
|
/* ignore space */
|
|
|
|
if dd == "." {
|
|
|
|
if dd == "." {
|
|
|
|