summaryrefslogtreecommitdiff
path: root/src/pkg/net/dnsconfig_unix.go
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2014-08-13 09:15:13 +0200
committerMichael Stapelberg <stapelberg@debian.org>2014-08-13 09:15:13 +0200
commit529609eb4df48905f8ed2ef746c642fb3113ad36 (patch)
treedcbb48025514e956597ea7c902b95aacdcbbe600 /src/pkg/net/dnsconfig_unix.go
parent384c13fcf3ee95bf43fac6c2407b49817fa4bce4 (diff)
parent64f344c0c94601934187163f7b353d009dc1b63f (diff)
downloadgolang-529609eb4df48905f8ed2ef746c642fb3113ad36.tar.gz
Merge tag 'upstream/1.3.1' into debian-sid
Upstream version 1.3.1
Diffstat (limited to 'src/pkg/net/dnsconfig_unix.go')
-rw-r--r--src/pkg/net/dnsconfig_unix.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/pkg/net/dnsconfig_unix.go b/src/pkg/net/dnsconfig_unix.go
index af288253e..db45716f1 100644
--- a/src/pkg/net/dnsconfig_unix.go
+++ b/src/pkg/net/dnsconfig_unix.go
@@ -75,19 +75,19 @@ func dnsReadConfig(filename string) (*dnsConfig, error) {
for i := 1; i < len(f); i++ {
s := f[i]
switch {
- case len(s) >= 6 && s[0:6] == "ndots:":
+ case hasPrefix(s, "ndots:"):
n, _, _ := dtoi(s, 6)
if n < 1 {
n = 1
}
conf.ndots = n
- case len(s) >= 8 && s[0:8] == "timeout:":
+ case hasPrefix(s, "timeout:"):
n, _, _ := dtoi(s, 8)
if n < 1 {
n = 1
}
conf.timeout = n
- case len(s) >= 8 && s[0:9] == "attempts:":
+ case hasPrefix(s, "attempts:"):
n, _, _ := dtoi(s, 9)
if n < 1 {
n = 1
@@ -103,3 +103,7 @@ func dnsReadConfig(filename string) (*dnsConfig, error) {
return conf, nil
}
+
+func hasPrefix(s, prefix string) bool {
+ return len(s) >= len(prefix) && s[:len(prefix)] == prefix
+}