Skip to content
No description, website, or topics provided.
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
_testdata/vendor/vendoredPkg
.travis.yml
LICENSE
MAINTAINERS
README.md
ast.go
ast_test.go
importer.go
importer_test.go

README.md

go-parse-utils

go-parse-utils is a collection of utilities for parsing code easily.

GoDoc Build Status codecov License Go Report Card

Install

go get gopkg.in/src-d/go-parse-utils.v1

Package AST

PackageAST retrieves the *ast.Package of a package in the given path.

pkg, err := parseutil.PackageAST("github.com/my/project")

Source code importer

The default importer.Importer of the Go standard library scans compiled objects, which can be painful to deal with in code generation, as it requires to go build before running go generate.

This packages provides an implementation of importer.Importer and importer.ImporterFrom that reads directly from source code if the package is in the GOPATH, otherwise (the stdlib, for example) falls back to the default importer in the standard library.

Features:

  • It is safe for concurrent use.
  • Caches packages after they are first imported.
importer := parseutil.NewImporter()
pkg, err := importer.Import("github.com/my/project")

License

MIT, see LICENSE

You can’t perform that action at this time.