Skip to content

kevinmu/go-parse-utils

 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%