Commit f23c37f6 authored by Ian Lance Taylor's avatar Ian Lance Taylor

net: remove imports of strconv

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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 9c258c6a
...@@ -271,8 +271,8 @@ var pkgDeps = map[string][]string{ ...@@ -271,8 +271,8 @@ var pkgDeps = map[string][]string{
// Basic networking. // Basic networking.
// Because net must be used by any package that wants to // 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. // do networking portably, it must have a small dependency set: just L0+basic os.
"net": {"L1", "CGO", "os", "syscall", "time", "internal/syscall/windows", "internal/singleflight"}, "net": {"L0", "CGO", "math/rand", "os", "sort", "syscall", "time", "internal/syscall/windows", "internal/singleflight"},
// NET enables use of basic network-related packages. // NET enables use of basic network-related packages.
"NET": { "NET": {
......
...@@ -9,7 +9,6 @@ package net ...@@ -9,7 +9,6 @@ package net
import ( import (
"os" "os"
"runtime" "runtime"
"strconv"
"sync" "sync"
"syscall" "syscall"
) )
...@@ -293,7 +292,7 @@ func goDebugNetDNS() (dnsMode string, debugLevel int) { ...@@ -293,7 +292,7 @@ func goDebugNetDNS() (dnsMode string, debugLevel int) {
return return
} }
if '0' <= s[0] && s[0] <= '9' { if '0' <= s[0] && s[0] <= '9' {
debugLevel, _ = strconv.Atoi(s) debugLevel, _, _ = dtoi(s, 0)
} else { } else {
dnsMode = s dnsMode = s
} }
......
...@@ -20,7 +20,6 @@ import ( ...@@ -20,7 +20,6 @@ import (
"io" "io"
"math/rand" "math/rand"
"os" "os"
"strconv"
"sync" "sync"
"time" "time"
) )
...@@ -371,7 +370,7 @@ func (o hostLookupOrder) String() string { ...@@ -371,7 +370,7 @@ func (o hostLookupOrder) String() string {
if s, ok := lookupOrderName[o]; ok { if s, ok := lookupOrderName[o]; ok {
return s return s
} }
return "hostLookupOrder=" + strconv.Itoa(int(o)) + "??" return "hostLookupOrder=" + itoa(int(o)) + "??"
} }
// goLookupHost is the native Go implementation of LookupHost. // goLookupHost is the native Go implementation of LookupHost.
......
...@@ -12,7 +12,6 @@ import ( ...@@ -12,7 +12,6 @@ import (
"reflect" "reflect"
"regexp" "regexp"
"sort" "sort"
"strconv"
"strings" "strings"
"testing" "testing"
) )
...@@ -184,14 +183,14 @@ func nslookupMX(name string) (mx []*MX, err error) { ...@@ -184,14 +183,14 @@ func nslookupMX(name string) (mx []*MX, err error) {
// golang.org mail exchanger = 2 alt1.aspmx.l.google.com. // 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.\-]+)$`) 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) { 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)}) mx = append(mx, &MX{fqdn(ans[3]), uint16(pref)})
} }
// windows nslookup syntax // windows nslookup syntax
// gmail.com MX preference = 30, mail exchanger = alt3.gmail-smtp-in.l.google.com // 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.\-]+)$`) 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) { 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)}) mx = append(mx, &MX{fqdn(ans[3]), uint16(pref)})
} }
return return
......
...@@ -7,13 +7,12 @@ ...@@ -7,13 +7,12 @@
package net package net
import ( import (
"strconv"
"time" "time"
) )
// Set keep alive period. // Set keep alive period.
func setKeepAlivePeriod(fd *netFD, d time.Duration) error { 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) _, e := fd.ctl.WriteAt([]byte(cmd), 0)
return e return e
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment