Skip to content

Commit

Permalink
Remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
opennota committed Nov 21, 2015
1 parent aa37591 commit 5914282
Showing 1 changed file with 0 additions and 54 deletions.
54 changes: 0 additions & 54 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,3 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package check

import (
"go/ast"
"go/build"
"go/parser"
"go/token"
"log"
"path/filepath"
"reflect"
)

func ASTFilesForPackage(path string, includeTestFiles bool) (*token.FileSet, []*ast.File) {
ctx := build.Default
pkg, err := ctx.Import(path, ".", 0)
if err != nil {
var err2 error
pkg, err2 = ctx.ImportDir(path, 0)
if err2 != nil {
log.Fatalf("cannot import package %s\n"+
"Errors are:\n"+
" %s\n"+
" %s",
path, err, err2)
}
}
fset := token.NewFileSet()
var astFiles []*ast.File
files := pkg.GoFiles
if includeTestFiles {
files = append(files, pkg.TestGoFiles...)
files = append(files, pkg.XTestGoFiles...)
}
for _, f := range files {
fn := filepath.Join(pkg.Dir, f)
f, err := parser.ParseFile(fset, fn, nil, 0)
if err != nil {
log.Fatalf("cannot parse file '%s'\n"+
"Error: %s", fn, err)
}
astFiles = append(astFiles, f)
}
return fset, astFiles
}

func TypeName(v interface{}) string {
t := reflect.TypeOf(v)
if t == nil {
return ""
}
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
return t.Name()
}

0 comments on commit 5914282

Please sign in to comment.