here

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2019 License: MIT Imports: 5 Imported by: 35

README

Here

GoDoc

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

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": [
    "here.go",
    "info.go",
    "module.go",
    "version.go"
  ],
  "Imports": [
    "encoding/json",
    "os",
    "os/exec",
    "path/filepath",
    "strings"
  ],
  "Deps": [
    "bytes",
    "context",
    "encoding",
    "encoding/base64",
    "encoding/binary",
    "encoding/json",
    "errors",
    "fmt",
    "internal/bytealg",
    "internal/cpu",
    "internal/fmtsort",
    "internal/poll",
    "internal/race",
    "internal/syscall/unix",
    "internal/testlog",
    "io",
    "math",
    "math/bits",
    "os",
    "os/exec",
    "path/filepath",
    "reflect",
    "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.12"
  },
  "GoEnv": {
    "CC": "clang",
    "CGO_CFLAGS": "-g -O2",
    "CGO_CPPFLAGS": "",
    "CGO_CXXFLAGS": "-g -O2",
    "CGO_ENABLED": "1",
    "CGO_FFLAGS": "-g -O2",
    "CGO_LDFLAGS": "-g -O2",
    "CXX": "clang++",
    "GCCGO": "gccgo",
    "GOARCH": "amd64",
    "GOBIN": "",
    "GOCACHE": "$HOME/Library/Caches/go-build",
    "GOEXE": "",
    "GOFLAGS": "",
    "GOGCCFLAGS": "-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zj/ktv0trrj4l79dfq0dkm1b6d40000gn/T/go-build762990333=/tmp/go-build -gno-record-gcc-switches -fno-common",
    "GOHOSTARCH": "amd64",
    "GOHOSTOS": "darwin",
    "GOMOD": "$GOPATH/src/github.com/gobuffalo/here/go.mod",
    "GOOS": "darwin",
    "GOPATH": "$GOPATH",
    "GOPROXY": "",
    "GORACE": "",
    "GOROOT": "/usr/local/go",
    "GOTMPDIR": "",
    "GOTOOLDIR": "/usr/local/go/pkg/tool/darwin_amd64",
    "PKG_CONFIG": "pkg-config"
  }
}
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"
  ],
  "Deps": [
    "bytes",
    "context",
    "encoding",
    "encoding/base64",
    "encoding/binary",
    "encoding/json",
    "errors",
    "fmt",
    "github.com/gobuffalo/here",
    "internal/bytealg",
    "internal/cpu",
    "internal/fmtsort",
    "internal/poll",
    "internal/race",
    "internal/syscall/unix",
    "internal/testlog",
    "io",
    "log",
    "math",
    "math/bits",
    "os",
    "os/exec",
    "path/filepath",
    "reflect",
    "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.12"
  },
  "GoEnv": {
    "CC": "clang",
    "CGO_CFLAGS": "-g -O2",
    "CGO_CPPFLAGS": "",
    "CGO_CXXFLAGS": "-g -O2",
    "CGO_ENABLED": "1",
    "CGO_FFLAGS": "-g -O2",
    "CGO_LDFLAGS": "-g -O2",
    "CXX": "clang++",
    "GCCGO": "gccgo",
    "GOARCH": "amd64",
    "GOBIN": "",
    "GOCACHE": "$HOME/Library/Caches/go-build",
    "GOEXE": "",
    "GOFLAGS": "",
    "GOGCCFLAGS": "-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zj/ktv0trrj4l79dfq0dkm1b6d40000gn/T/go-build976603462=/tmp/go-build -gno-record-gcc-switches -fno-common",
    "GOHOSTARCH": "amd64",
    "GOHOSTOS": "darwin",
    "GOMOD": "$GOPATH/src/github.com/gobuffalo/here/go.mod",
    "GOOS": "darwin",
    "GOPATH": "$GOPATH",
    "GOPROXY": "",
    "GORACE": "",
    "GOROOT": "/usr/local/go",
    "GOTMPDIR": "",
    "GOTOOLDIR": "/usr/local/go/pkg/tool/darwin_amd64",
    "PKG_CONFIG": "pkg-config"
  }
}
By Package
$ here pkg github.com/gobuffalo/genny

{
  "Dir": "$GOPATH/pkg/mod/github.com/gobuffalo/genny@v0.2.0",
  "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": "",
  "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.2.0",
    "GoMod": "$GOPATH/pkg/mod/cache/download/github.com/gobuffalo/genny/@v/v0.2.0.mod",
    "GoVersion": ""
  },
  "GoEnv": {
    "CC": "clang",
    "CGO_CFLAGS": "-g -O2",
    "CGO_CPPFLAGS": "",
    "CGO_CXXFLAGS": "-g -O2",
    "CGO_ENABLED": "1",
    "CGO_FFLAGS": "-g -O2",
    "CGO_LDFLAGS": "-g -O2",
    "CXX": "clang++",
    "GCCGO": "gccgo",
    "GOARCH": "amd64",
    "GOBIN": "",
    "GOCACHE": "$HOME/Library/Caches/go-build",
    "GOEXE": "",
    "GOFLAGS": "",
    "GOGCCFLAGS": "-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zj/ktv0trrj4l79dfq0dkm1b6d40000gn/T/go-build207410055=/tmp/go-build -gno-record-gcc-switches -fno-common",
    "GOHOSTARCH": "amd64",
    "GOHOSTOS": "darwin",
    "GOMOD": "$GOPATH/src/github.com/gobuffalo/here/go.mod",
    "GOOS": "darwin",
    "GOPATH": "$GOPATH",
    "GOPROXY": "",
    "GORACE": "",
    "GOROOT": "/usr/local/go",
    "GOTMPDIR": "",
    "GOTOOLDIR": "/usr/local/go/pkg/tool/darwin_amd64",
    "PKG_CONFIG": "pkg-config"
  }
}

Documentation

Index

Constants

View Source
const Version = "v0.1.0"

Version of here

Variables

This section is empty.

Functions

This section is empty.

Types

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
	GoEnv       map[string]string // go env -json
}

Info represents details about the directory/package

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) Getenv

func (i Info) Getenv(k string) string

Getenv is a helper function to mimic os.Getenv behavior.

func (Info) GoPath

func (i Info) GoPath() string

GoPath returns the GOPATH ENV var

func (Info) Has

func (i Info) Has(k string) bool

Has checks if the ENV variable is in the GoEnv

func (Info) IsZero

func (i Info) IsZero() bool

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

func (Info) Mods

func (i Info) Mods() bool

Mods returns whether Go modules are used in this directory/package.

func (Info) ModuleName

func (i Info) ModuleName() string

ModuleName returns the name of the current module, or if not using modules, the current package. These *might* not match.

func (Info) String

func (i Info) String() string

type Module

type Module struct {
	Path      string `json:"Path"`
	Main      bool   `json:"Main"`
	Dir       string `json:"Dir"`
	GoMod     string `json:"GoMod"`
	GoVersion string `json:"GoVersion"`
}

func (Module) IsZero

func (i Module) IsZero() bool

func (Module) String

func (i Module) String() string

Directories

Path Synopsis
cmd
here command

Jump to

Keyboard shortcuts

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