Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(635)

Delta Between Two Patch Sets: src/cmd/fix/netipv6zone.go

Issue 6849045: code review 6849045: net, cmd/fix: add IPv6 scoped addressing zone to INET, ... (Closed)
Left Patch Set: diff -r fc4e67d82024 https://code.google.com/p/go Created 11 years, 4 months ago
Right Patch Set: diff -r c200281fac50 https://code.google.com/p/go Created 11 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/cmd/fix/netipv6zone_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package main
6
7 import "go/ast"
8
9 func init() {
10 register(netipv6zoneFix)
11 }
12
13 var netipv6zoneFix = fix{
14 "netipv6zone",
15 "2012-11-26",
16 netipv6zone,
17 `Adapt element key to IPNet, IPAddr, UDPAddr or TCPAddr composite litera ls.
18
19 https://codereview.appspot.com/6849045/
20 `,
21 }
22
23 func netipv6zone(f *ast.File) bool {
24 if !imports(f, "net") {
25 return false
26 }
27
28 fixed := false
29 walk(f, func(n interface{}) {
30 cl, ok := n.(*ast.CompositeLit)
31 if !ok {
32 return
33 }
34 se, ok := cl.Type.(*ast.SelectorExpr)
35 if !ok {
36 return
37 }
38 if !isTopName(se.X, "net") || se.Sel == nil {
39 return
40 }
41 switch ss := se.Sel.String(); ss {
42 case "IPNet", "IPAddr", "UDPAddr", "TCPAddr":
43 for i, e := range cl.Elts {
44 if _, ok := e.(*ast.KeyValueExpr); ok {
45 break
46 }
47 switch i {
48 case 0:
49 cl.Elts[i] = &ast.KeyValueExpr{
50 Key: ast.NewIdent("IP"),
51 Value: e,
52 }
53 case 1:
54 if ss == "IPNet" {
55 cl.Elts[i] = &ast.KeyValueExpr{
56 Key: ast.NewIdent("Mas k"),
57 Value: e,
58 }
59 } else {
60 cl.Elts[i] = &ast.KeyValueExpr{
61 Key: ast.NewIdent("Por t"),
62 Value: e,
63 }
64 }
65 }
66 fixed = true
67 }
68 }
69 })
70 return fixed
71 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b