~ubuntu-branches/ubuntu/saucy/golang/saucy

« back to all changes in this revision

Viewing changes to src/cmd/fix/signal.go

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-07-08 05:52:37 UTC
  • mfrom: (29.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130708055237-at01839e0hp8z3ni
Tags: 2:1.1-1ubuntu1
016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
4
 
 
5
 
package main
6
 
 
7
 
import (
8
 
        "go/ast"
9
 
        "strings"
10
 
)
11
 
 
12
 
func init() {
13
 
        register(signalFix)
14
 
}
15
 
 
16
 
var signalFix = fix{
17
 
        "signal",
18
 
        "2011-06-29",
19
 
        signal,
20
 
        `Adapt code to types moved from os/signal to signal.
21
 
 
22
 
http://codereview.appspot.com/4437091
23
 
`,
24
 
}
25
 
 
26
 
func signal(f *ast.File) (fixed bool) {
27
 
        if !imports(f, "os/signal") {
28
 
                return
29
 
        }
30
 
 
31
 
        walk(f, func(n interface{}) {
32
 
                s, ok := n.(*ast.SelectorExpr)
33
 
 
34
 
                if !ok || !isTopName(s.X, "signal") {
35
 
                        return
36
 
                }
37
 
 
38
 
                sel := s.Sel.String()
39
 
                if sel == "Signal" || sel == "UnixSignal" || strings.HasPrefix(sel, "SIG") {
40
 
                        addImport(f, "os")
41
 
                        s.X = &ast.Ident{Name: "os"}
42
 
                        fixed = true
43
 
                }
44
 
        })
45
 
 
46
 
        if fixed && !usesImport(f, "os/signal") {
47
 
                deleteImport(f, "os/signal")
48
 
        }
49
 
        return
50
 
}