From fa086b0feda7436f405dd81568c92ba74b13a6e2 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Sat, 30 Nov 2019 16:47:09 -0500 Subject: [PATCH] added some docs --- current.go | 1 + here.go | 3 +++ there/there.go | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/current.go b/current.go index 927633c..fb5b3e8 100644 --- a/current.go +++ b/current.go @@ -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() } diff --git a/here.go b/here.go index 3b6fb5b..cec1d76 100644 --- a/here.go +++ b/here.go @@ -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{ diff --git a/there/there.go b/there/there.go index 5673faf..51e333b 100644 --- a/there/there.go +++ b/there/there.go @@ -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() }