Skip to content

Commit

Permalink
added some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Nov 30, 2019
1 parent bd04cec commit fa086b0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions current.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func (h Here) Current() (Info, error) {
return h.current, h.curErr
}

// Current returns the Info representing the current Go module
func Current() (Info, error) {
return New().Current()
}
3 changes: 3 additions & 0 deletions here.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ type Here struct {
current Info
}

// New returns a Here type that will cache
// all results. This speeds up repeated calls,
// and can be useful for testing.
func New() Here {
return Here{
infos: &infoMap{
Expand Down
14 changes: 14 additions & 0 deletions there/there.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,28 @@ import "github.com/gobuffalo/here"

var cache = here.New()

// Dir attempts to gather info for the requested directory.
// Results are cached globally inside the package.
func Dir(p string) (here.Info, error) {
return cache.Dir(p)
}

// Package attempts to gather info for the requested package.
//
// From the `go help list` docs:
// The -find flag causes list to identify the named packages but not
// resolve their dependencies: the Imports and Deps lists will be empty.
//
// A workaround for this issue is to use the `Dir` field in the
// returned `Info` value and pass it to the `Dir(string) (Info, error)`
// function to return the complete data.
// Results are cached globally inside the package.
func Package(p string) (here.Info, error) {
return cache.Package(p)
}

// Results are cached globally inside the package.
// Current returns the Info representing the current Go module
func Current() (here.Info, error) {
return cache.Current()
}

0 comments on commit fa086b0

Please sign in to comment.