Skip to content

Commit

Permalink
Merge pull request #3 from gobuffalo/there
Browse files Browse the repository at this point in the history
added there package
  • Loading branch information
markbates authored Nov 30, 2019
2 parents 149d599 + fa086b0 commit f233917
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 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()
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ require (
github.com/kr/pretty v0.1.0 // indirect
github.com/stretchr/testify v1.4.0
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.2.5 // indirect
gopkg.in/yaml.v2 v2.2.7 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
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
31 changes: 31 additions & 0 deletions there/there.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package there

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 f233917

Please sign in to comment.