]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/fix: remove redundant 0 port
authorTyler Bunnell <tylerbunnell@gmail.com>
Thu, 7 Mar 2013 10:06:19 +0000 (19:06 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Thu, 7 Mar 2013 10:06:19 +0000 (19:06 +0900)
Fixes #4505.

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7468043

src/cmd/fix/netipv6zone.go
src/cmd/fix/netipv6zone_test.go

index 587b9ffec6f194df3ae86a3fe013e24ee1ffc072..bbaf5fc08ceb367f64cfcd2103ef56756e17c16d 100644 (file)
@@ -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
index 229daa386d5f92b2094a83a1cc591a073a0d8fc8..569363e1f3b58419ce01dc13e06e96606f457eb7 100644 (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
 }
 `,
        },