here

package module
v0.6.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2022 License: MIT Imports: 9 Imported by: 33

README

Here

GoDoc

Here will get you accurate Go information about the directory of package requested.

Requirements
  • Go 1.13+
  • Go Modules

CLI

While you can use the tool via its API, you can also use the CLI to get a JSON version of the data.

Installation
$ go get github.com/gobuffalo/here/cmd/here
Usage
Default
$ here

{
  "Dir": "$GOPATH/src/github.com/gobuffalo/here",
  "ImportPath": "github.com/gobuffalo/here",
  "Name": "here",
  "Doc": "",
  "Target": "$GOPATH/pkg/darwin_amd64/github.com/gobuffalo/here.a",
  "Root": "$GOPATH",
  "Match": [
    "."
  ],
  "Stale": true,
  "StaleReason": "not installed but available in build cache",
  "GoFiles": [
    "current.go",
    "dir.go",
    "here.go",
    "info.go",
    "info_map.go",
    "module.go",
    "pkg.go",
    "version.go"
  ],
  "Imports": [
    "bytes",
    "encoding/json",
    "fmt",
    "os",
    "os/exec",
    "path/filepath",
    "regexp",
    "sync"
  ],
  "Deps": [
    "bytes",
    "context",
    "encoding",
    "encoding/base64",
    "encoding/binary",
    "encoding/json",
    "errors",
    "fmt",
    "internal/bytealg",
    "internal/cpu",
    "internal/fmtsort",
    "internal/oserror",
    "internal/poll",
    "internal/race",
    "internal/reflectlite",
    "internal/syscall/unix",
    "internal/testlog",
    "io",
    "math",
    "math/bits",
    "os",
    "os/exec",
    "path/filepath",
    "reflect",
    "regexp",
    "regexp/syntax",
    "runtime",
    "runtime/internal/atomic",
    "runtime/internal/math",
    "runtime/internal/sys",
    "sort",
    "strconv",
    "strings",
    "sync",
    "sync/atomic",
    "syscall",
    "time",
    "unicode",
    "unicode/utf16",
    "unicode/utf8",
    "unsafe"
  ],
  "TestGoFiles": [
    "current_test.go",
    "dir_test.go",
    "here_test.go",
    "info_test.go",
    "module_test.go",
    "pkg_test.go"
  ],
  "TestImports": [
    "github.com/stretchr/testify/require",
    "os",
    "path/filepath",
    "testing"
  ],
  "Module": {
    "Path": "github.com/gobuffalo/here",
    "Main": true,
    "Dir": "$GOPATH/src/github.com/gobuffalo/here",
    "GoMod": "$GOPATH/src/github.com/gobuffalo/here/go.mod",
    "GoVersion": "1.13"
  }
}
By Directory
$ here cmd/here

{
  "Dir": "$GOPATH/src/github.com/gobuffalo/here/cmd/here",
  "ImportPath": "github.com/gobuffalo/here/cmd/here",
  "Name": "main",
  "Doc": "",
  "Target": "$GOPATH/bin/here",
  "Root": "$GOPATH",
  "Match": [
    "."
  ],
  "Stale": false,
  "StaleReason": "",
  "GoFiles": [
    "main.go"
  ],
  "Imports": [
    "fmt",
    "github.com/gobuffalo/here",
    "log",
    "os",
    "os/exec"
  ],
  "Deps": [
    "bytes",
    "context",
    "encoding",
    "encoding/base64",
    "encoding/binary",
    "encoding/json",
    "errors",
    "fmt",
    "github.com/gobuffalo/here",
    "internal/bytealg",
    "internal/cpu",
    "internal/fmtsort",
    "internal/oserror",
    "internal/poll",
    "internal/race",
    "internal/reflectlite",
    "internal/syscall/unix",
    "internal/testlog",
    "io",
    "log",
    "math",
    "math/bits",
    "os",
    "os/exec",
    "path/filepath",
    "reflect",
    "regexp",
    "regexp/syntax",
    "runtime",
    "runtime/internal/atomic",
    "runtime/internal/math",
    "runtime/internal/sys",
    "sort",
    "strconv",
    "strings",
    "sync",
    "sync/atomic",
    "syscall",
    "time",
    "unicode",
    "unicode/utf16",
    "unicode/utf8",
    "unsafe"
  ],
  "TestGoFiles": null,
  "TestImports": null,
  "Module": {
    "Path": "github.com/gobuffalo/here",
    "Main": true,
    "Dir": "$GOPATH/src/github.com/gobuffalo/here",
    "GoMod": "$GOPATH/src/github.com/gobuffalo/here/go.mod",
    "GoVersion": "1.13"
  }
}
By Package
$ here pkg github.com/gobuffalo/genny

{
  "Dir": "$GOPATH/pkg/mod/github.com/gobuffalo/genny@v0.4.1",
  "ImportPath": "github.com/gobuffalo/genny",
  "Name": "genny",
  "Doc": "Package genny is a _framework_ for writing modular generators, it however, doesn't actually generate anything.",
  "Target": "",
  "Root": "$GOPATH/pkg/mod/github.com/gobuffalo/genny@v0.4.1",
  "Match": [
    "github.com/gobuffalo/genny"
  ],
  "Stale": true,
  "StaleReason": "build ID mismatch",
  "GoFiles": [
    "confirm.go",
    "dir.go",
    "disk.go",
    "dry_runner.go",
    "events.go",
    "file.go",
    "force.go",
    "generator.go",
    "genny.go",
    "group.go",
    "helpers.go",
    "logger.go",
    "replacer.go",
    "results.go",
    "runner.go",
    "step.go",
    "transformer.go",
    "version.go",
    "wet_runner.go"
  ],
  "Imports": null,
  "Deps": null,
  "TestGoFiles": [
    "dry_runner_test.go",
    "file_test.go",
    "force_test.go",
    "generator_test.go",
    "genny_test.go",
    "group_test.go",
    "helpers_test.go",
    "replacer_test.go",
    "results_test.go",
    "runner_test.go",
    "step_test.go",
    "transformer_test.go",
    "wet_runner_test.go"
  ],
  "TestImports": null,
  "Module": {
    "Path": "github.com/gobuffalo/genny",
    "Main": false,
    "Dir": "$GOPATH/pkg/mod/github.com/gobuffalo/genny@v0.4.1",
    "GoMod": "$GOPATH/pkg/mod/cache/download/github.com/gobuffalo/genny/@v/v0.4.1.mod",
    "GoVersion": "1.13"
  }
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "development"

Version of here

Functions

This section is empty.

Types

type Here added in v0.4.0

type Here struct {
	// contains filtered or unexported fields
}

func New added in v0.4.0

func New() Here

New returns a Here type that will cache all results. This speeds up repeated calls, and can be useful for testing.

func (Here) Current added in v0.4.0

func (h Here) Current() (Info, error)

Current returns the Info representing the current Go module

func (Here) Dir added in v0.4.0

func (h Here) Dir(p string) (Info, error)

Dir attempts to gather info for the requested directory.

func (Here) Package added in v0.4.0

func (h Here) Package(p string) (Info, error)

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.

type Info

type Info struct {
	Dir         string
	ImportPath  string
	Name        string
	Doc         string
	Target      string
	Root        string
	Match       []string
	Stale       bool
	StaleReason string
	GoFiles     []string
	Imports     []string
	Deps        []string
	TestGoFiles []string
	TestImports []string
	Module      Module
}

Info represents details about the directory/package

func Current added in v0.2.2

func Current() (Info, error)

Current returns the Info representing the current Go module

func Dir

func Dir(p string) (Info, error)

Dir attempts to gather info for the requested directory.

func Package

func Package(p string) (Info, error)

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.

func (Info) IsZero

func (i Info) IsZero() bool

IsZero checks if the type has been filled with rich chocolately data goodness

func (Info) Parse added in v0.6.0

func (i Info) Parse(p string) (Path, error)

func (Info) String

func (i Info) String() string

type Module

type Module struct {
	Path      string
	Main      bool
	Dir       string
	GoMod     string
	GoVersion string
}

func (Module) IsZero

func (i Module) IsZero() bool

func (Module) String

func (i Module) String() string

type Path added in v0.6.0

type Path struct {
	Pkg  string
	Name string
}

func (Path) String added in v0.6.0

func (p Path) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL