]> Cypherpunks repositories - gostls13.git/commitdiff
net: remove imports of strconv
authorIan Lance Taylor <iant@golang.org>
Mon, 5 Oct 2015 18:05:10 +0000 (11:05 -0700)
committerIan Lance Taylor <iant@golang.org>
Mon, 5 Oct 2015 22:39:12 +0000 (22:39 +0000)
The net package already has support for limited uses of the strconv
package.  Despite this, a few uses of strconv have crept in over time.
Remove them and use the existing net support instead.

Change-Id: Icdb4bdaa8e1197f1119a96cddcf548ed4a551b74
Reviewed-on: https://go-review.googlesource.com/15400
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/go/build/deps_test.go
src/net/conf.go
src/net/dnsclient_unix.go
src/net/lookup_windows_test.go
src/net/tcpsockopt_plan9.go

index 7cea94927d77ce59650e5efedfba3fd389082c45..62bcb12a23f637e8c4939f90ba6a5569b7d66def 100644 (file)
@@ -271,8 +271,8 @@ var pkgDeps = map[string][]string{
 
        // Basic networking.
        // Because net must be used by any package that wants to
-       // do networking portably, it must have a small dependency set: just L1+basic os.
-       "net": {"L1", "CGO", "os", "syscall", "time", "internal/syscall/windows", "internal/singleflight"},
+       // do networking portably, it must have a small dependency set: just L0+basic os.
+       "net": {"L0", "CGO", "math/rand", "os", "sort", "syscall", "time", "internal/syscall/windows", "internal/singleflight"},
 
        // NET enables use of basic network-related packages.
        "NET": {
index c92e579d7e6852e4e929a2c1dc8a1e7dfe69789d..ddaa978f4f63c5b5286c941b3bf4411017383363 100644 (file)
@@ -9,7 +9,6 @@ package net
 import (
        "os"
        "runtime"
-       "strconv"
        "sync"
        "syscall"
 )
@@ -293,7 +292,7 @@ func goDebugNetDNS() (dnsMode string, debugLevel int) {
                        return
                }
                if '0' <= s[0] && s[0] <= '9' {
-                       debugLevel, _ = strconv.Atoi(s)
+                       debugLevel, _, _ = dtoi(s, 0)
                } else {
                        dnsMode = s
                }
index 1fbe085bbfc8ca745e87d31caaa525ef85c24256..94282ee79e95397bedd79340a9edcce58541e441 100644 (file)
@@ -20,7 +20,6 @@ import (
        "io"
        "math/rand"
        "os"
-       "strconv"
        "sync"
        "time"
 )
@@ -371,7 +370,7 @@ func (o hostLookupOrder) String() string {
        if s, ok := lookupOrderName[o]; ok {
                return s
        }
-       return "hostLookupOrder=" + strconv.Itoa(int(o)) + "??"
+       return "hostLookupOrder=" + itoa(int(o)) + "??"
 }
 
 // goLookupHost is the native Go implementation of LookupHost.
index 3f64d8cec89c52d2c8a836ee11c4855dcdd115bc..8368ad4bd5f8395fbedb570dcf171bffd7d22372 100644 (file)
@@ -12,7 +12,6 @@ import (
        "reflect"
        "regexp"
        "sort"
-       "strconv"
        "strings"
        "testing"
 )
@@ -184,14 +183,14 @@ func nslookupMX(name string) (mx []*MX, err error) {
        // golang.org      mail exchanger = 2 alt1.aspmx.l.google.com.
        rx := regexp.MustCompile(`(?m)^([a-z0-9.\-]+)\s+mail exchanger\s*=\s*([0-9]+)\s*([a-z0-9.\-]+)$`)
        for _, ans := range rx.FindAllStringSubmatch(r, -1) {
-               pref, _ := strconv.Atoi(ans[2])
+               pref, _, _ := dtoi(ans[2], 0)
                mx = append(mx, &MX{fqdn(ans[3]), uint16(pref)})
        }
        // windows nslookup syntax
        // gmail.com       MX preference = 30, mail exchanger = alt3.gmail-smtp-in.l.google.com
        rx = regexp.MustCompile(`(?m)^([a-z0-9.\-]+)\s+MX preference\s*=\s*([0-9]+)\s*,\s*mail exchanger\s*=\s*([a-z0-9.\-]+)$`)
        for _, ans := range rx.FindAllStringSubmatch(r, -1) {
-               pref, _ := strconv.Atoi(ans[2])
+               pref, _, _ := dtoi(ans[2], 0)
                mx = append(mx, &MX{fqdn(ans[3]), uint16(pref)})
        }
        return
index 9abe186cecb4ea4160d196b86c282c95df605a73..157282abd34b7ec0e4746f3b2c1a570a43689bf3 100644 (file)
@@ -7,13 +7,12 @@
 package net
 
 import (
-       "strconv"
        "time"
 )
 
 // Set keep alive period.
 func setKeepAlivePeriod(fd *netFD, d time.Duration) error {
-       cmd := "keepalive " + strconv.Itoa(int(d/time.Millisecond))
+       cmd := "keepalive " + itoa(int(d/time.Millisecond))
        _, e := fd.ctl.WriteAt([]byte(cmd), 0)
        return e
 }