mirror of
https://github.com/golang/go
synced 2024-11-26 14:46:47 -07:00
cmd/fix: remove redundant 0 port
Fixes #4505. R=golang-dev, mikioh.mikioh CC=golang-dev https://golang.org/cl/7468043
This commit is contained in:
parent
bcb1da7065
commit
ae7aa345db
@ -57,10 +57,15 @@ func netipv6zone(f *ast.File) bool {
|
||||
Value: e,
|
||||
}
|
||||
} else {
|
||||
cl.Elts[i] = &ast.KeyValueExpr{
|
||||
Key: ast.NewIdent("Port"),
|
||||
Value: e,
|
||||
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
|
||||
|
@ -26,7 +26,8 @@ func f() net.Addr {
|
||||
c := &net.IPAddr{ip1}
|
||||
sub(&net.UDPAddr{ip2, 12345})
|
||||
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
|
||||
@ -44,7 +45,8 @@ func f() net.Addr {
|
||||
c := &net.IPAddr{IP: ip1}
|
||||
sub(&net.UDPAddr{IP: ip2, Port: 12345})
|
||||
d := &net.TCPAddr{IP: ip3, Port: 54321}
|
||||
return &net.TCPAddr{IP: ip4}, nil
|
||||
e := &net.TCPAddr{IP: ip4}
|
||||
return &net.TCPAddr{IP: ip5}, nil
|
||||
}
|
||||
`,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user