Documentation ¶
Index ¶
- func FindImportPath(dir string) (string, error)
- func FindPackageDefinitionDir(importPath string, workDir string) (string, error)
- func FindPackageNameByDir(dir string) string
- func InspectDirectory(dir string) (info *importPathInfo, err error)
- func InspectImport(importPath string, workDir string) (info *importPathInfo, err error)
- type Import
- type LocationType
- type Package
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindImportPath ¶
Find import path assuming that directory contains Go package.
For projects with 'vendor' directory it will return path in the vendor dir.
It will check all upper directories checking each of them as (a) they have go.mod file (b) directory is under GOROOT/GOPATH
func FindPackageDefinitionDir ¶
Find package definition with respect to gomodules
func FindPackageNameByDir ¶
Find package name by directory: scans go file to detect package definition and uses path detection as fail-over
func InspectDirectory ¶
func InspectImport ¶
Types ¶
type Import ¶
type Import struct { Path string // example.com/project/alfa/beta/gamma Package string // gamma Location string // /opt/go/src/example.com/project/alfa/beta/gamma RootPackageLocation string // /opt/go/src/example.com/project/alfa Type LocationType }
func InspectImportByDir ¶
Aggregated information about directory
type LocationType ¶
type LocationType int
const ( Local LocationType = 0 GoMod LocationType = 1 InLocalVendor LocationType = 2 GoPath LocationType = 3 GoRoot LocationType = 4 GoCache LocationType = 5 )
Click to show internal directories.
Click to hide internal directories.