cmd/fix: revert IPv6 scoped address zone support of IPNet
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7554051
diff --git a/src/cmd/fix/netipv6zone.go b/src/cmd/fix/netipv6zone.go
index bbaf5fc..fe973a2 100644
--- a/src/cmd/fix/netipv6zone.go
+++ b/src/cmd/fix/netipv6zone.go
@@ -14,7 +14,7 @@
"netipv6zone",
"2012-11-26",
netipv6zone,
- `Adapt element key to IPNet, IPAddr, UDPAddr or TCPAddr composite literals.
+ `Adapt element key to IPAddr, UDPAddr or TCPAddr composite literals.
https://codereview.appspot.com/6849045/
`,
@@ -39,7 +39,7 @@
return
}
switch ss := se.Sel.String(); ss {
- case "IPNet", "IPAddr", "UDPAddr", "TCPAddr":
+ case "IPAddr", "UDPAddr", "TCPAddr":
for i, e := range cl.Elts {
if _, ok := e.(*ast.KeyValueExpr); ok {
break
@@ -51,21 +51,13 @@
Value: e,
}
case 1:
- if ss == "IPNet" {
+ if e.(*ast.BasicLit).Value == "0" {
+ cl.Elts = append(cl.Elts[:i], cl.Elts[i+1:]...)
+ } else {
cl.Elts[i] = &ast.KeyValueExpr{
- Key: ast.NewIdent("Mask"),
+ Key: ast.NewIdent("Port"),
Value: e,
}
- } else {
- if e.(*ast.BasicLit).Value == "0" {
- cl.Elts = append(cl.Elts[:i], cl.Elts[i+1:]...)
- } else {
- cl.Elts[i] = &ast.KeyValueExpr{
- Key: ast.NewIdent("Port"),
- Value: e,
- }
- }
-
}
}
fixed = true
diff --git a/src/cmd/fix/netipv6zone_test.go b/src/cmd/fix/netipv6zone_test.go
index 569363e..0fab0053 100644
--- a/src/cmd/fix/netipv6zone_test.go
+++ b/src/cmd/fix/netipv6zone_test.go
@@ -15,18 +15,11 @@
import "net"
-var a = []struct {
- *net.IPNet
-}{
- &net.IPNet{net.ParseIP("2001:DB8::"), net.IPMask(net.ParseIP("ffff:ffff:ffff::"))},
-}
-
func f() net.Addr {
- b := net.IPNet{net.IPv4(127, 0, 0, 1), net.IPv4Mask(255, 0, 0, 0)}
- c := &net.IPAddr{ip1}
+ a := &net.IPAddr{ip1}
sub(&net.UDPAddr{ip2, 12345})
- d := &net.TCPAddr{IP: ip3, Port: 54321}
- e := &net.TCPAddr{ip4, 0}
+ c := &net.TCPAddr{IP: ip3, Port: 54321}
+ d := &net.TCPAddr{ip4, 0}
return &net.TCPAddr{ip5}, nil
}
`,
@@ -34,18 +27,11 @@
import "net"
-var a = []struct {
- *net.IPNet
-}{
- &net.IPNet{IP: net.ParseIP("2001:DB8::"), Mask: net.IPMask(net.ParseIP("ffff:ffff:ffff::"))},
-}
-
func f() net.Addr {
- b := net.IPNet{IP: net.IPv4(127, 0, 0, 1), Mask: net.IPv4Mask(255, 0, 0, 0)}
- c := &net.IPAddr{IP: ip1}
+ a := &net.IPAddr{IP: ip1}
sub(&net.UDPAddr{IP: ip2, Port: 12345})
- d := &net.TCPAddr{IP: ip3, Port: 54321}
- e := &net.TCPAddr{IP: ip4}
+ c := &net.TCPAddr{IP: ip3, Port: 54321}
+ d := &net.TCPAddr{IP: ip4}
return &net.TCPAddr{IP: ip5}, nil
}
`,