1
// Copyright 2011 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.
12
register(netudpgroupFix)
15
var netudpgroupFix = fix{
19
`Adapt 1-argument calls of net.(*UDPConn).JoinGroup, LeaveGroup to use 2-argument form.
21
http://codereview.appspot.com/4815074
25
func netudpgroup(f *ast.File) bool {
26
if !imports(f, "net") {
31
for _, d := range f.Decls {
32
fd, ok := d.(*ast.FuncDecl)
33
if !ok || fd.Body == nil {
36
walk(fd.Body, func(n interface{}) {
37
ce, ok := n.(*ast.CallExpr)
41
se, ok := ce.Fun.(*ast.SelectorExpr)
42
if !ok || len(ce.Args) != 1 {
45
switch se.Sel.String() {
46
case "JoinGroup", "LeaveGroup":
47
// c.JoinGroup(a) -> c.JoinGroup(nil, a)
48
// c.LeaveGroup(a) -> c.LeaveGroup(nil, a)
50
ce.Args = make([]ast.Expr, 2)
51
ce.Args[0] = ast.NewIdent("nil")