1
0
mirror of https://github.com/golang/go synced 2024-11-26 17:26:56 -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:
Tyler Bunnell 2013-03-07 19:06:19 +09:00 committed by Mikio Hara
parent bcb1da7065
commit ae7aa345db
2 changed files with 12 additions and 5 deletions

View File

@ -56,12 +56,17 @@ func netipv6zone(f *ast.File) bool {
Key: ast.NewIdent("Mask"),
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
}

View File

@ -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
}
`,
},