Commit ae7aa345 authored by Tyler Bunnell's avatar Tyler Bunnell Committed by Mikio Hara

cmd/fix: remove redundant 0 port

Fixes #4505.

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7468043
parent bcb1da70
...@@ -57,10 +57,15 @@ func netipv6zone(f *ast.File) bool { ...@@ -57,10 +57,15 @@ func netipv6zone(f *ast.File) bool {
Value: e, Value: e,
} }
} else { } else {
cl.Elts[i] = &ast.KeyValueExpr{ if e.(*ast.BasicLit).Value == "0" {
Key: ast.NewIdent("Port"), cl.Elts = append(cl.Elts[:i], cl.Elts[i+1:]...)
Value: e, } else {
cl.Elts[i] = &ast.KeyValueExpr{
Key: ast.NewIdent("Port"),
Value: e,
}
} }
} }
} }
fixed = true fixed = true
......
...@@ -26,7 +26,8 @@ func f() net.Addr { ...@@ -26,7 +26,8 @@ func f() net.Addr {
c := &net.IPAddr{ip1} c := &net.IPAddr{ip1}
sub(&net.UDPAddr{ip2, 12345}) sub(&net.UDPAddr{ip2, 12345})
d := &net.TCPAddr{IP: ip3, Port: 54321} d := &net.TCPAddr{IP: ip3, Port: 54321}
return &net.TCPAddr{ip4}, nil e := &net.TCPAddr{ip4, 0}
return &net.TCPAddr{ip5}, nil
} }
`, `,
Out: `package main Out: `package main
...@@ -44,7 +45,8 @@ func f() net.Addr { ...@@ -44,7 +45,8 @@ func f() net.Addr {
c := &net.IPAddr{IP: ip1} c := &net.IPAddr{IP: ip1}
sub(&net.UDPAddr{IP: ip2, Port: 12345}) sub(&net.UDPAddr{IP: ip2, Port: 12345})
d := &net.TCPAddr{IP: ip3, Port: 54321} d := &net.TCPAddr{IP: ip3, Port: 54321}
return &net.TCPAddr{IP: ip4}, nil e := &net.TCPAddr{IP: ip4}
return &net.TCPAddr{IP: ip5}, nil
} }
`, `,
}, },
......
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