Documentation
¶
Index ¶
- Constants
- Variables
- func CmpInt(x, y string) int
- func CompareSemVer(v, w string) int
- func CompareVersion(x, y string) int
- func FindGoModDir(dir string) (string, error)
- func FindGoModDirSubPath(dir string) ([]string, string, error)
- func FromToolchain(name string) string
- func GetGoVersionOutput(goBinary string) (string, error)
- func GetModPath(dir string) (string, error)
- func IsValidSemVer(v string) bool
- func IsValidVersion(x string) bool
- func ListFiles(dir string, args []string) ([]string, error)
- func ListPackagePaths(dir string, mod string, args []string) ([]string, error)
- func ListRelativeFiles(dir string, args []string) ([]string, error)
- func ModCompare(path string, x, y string) int
- func PkgWithinModule(pkgPath string, module string) (suffix string, ok bool)
- func ResolveMainModule(dir string) (subPaths []string, mainModule string, err error)
- func ResolveModulePkgPath(dir string) (mainModPath string, pkgPath string, err error)
- type GoVersion
- type LoadPackageOptions
- type ModVersion
- type Package
- type PackageError
- type VendorInfo
- type Version
Constants ¶
View Source
const ( GO_MAJOR_1 = 1 GO_VERSION_16 = 16 // unsupported GO_VERSION_17 = 17 GO_VERSION_18 = 18 GO_VERSION_19 = 19 GO_VERSION_20 = 20 GO_VERSION_21 = 21 GO_VERSION_22 = 22 GO_VERSION_23 = 23 GO_VERSION_24 = 24 GO_VERSION_25 = 25 )
Variables ¶
View Source
var ErrGoModDoesNotHaveModule = errors.New("go.mod does not have module")
View Source
var ErrGoModNotFound = errors.New("go.mod not found")
Functions ¶
func CompareSemVer ¶ added in v1.0.26
func CompareVersion ¶ added in v1.0.26
func FindGoModDir ¶ added in v1.0.37
func FindGoModDirSubPath ¶ added in v1.0.45
FindGoModDirSubPath find go.mod by traversing dir bottom up, upon finding a go.mod file, it returns the corresponding sub path and root dir
func FromToolchain ¶ added in v1.0.26
func GetGoVersionOutput ¶
func GetModPath ¶ added in v1.0.37
func IsValidSemVer ¶ added in v1.0.26
func IsValidVersion ¶ added in v1.0.26
func ListFiles ¶ added in v1.1.0
ListFiles list all go files, return a list of absolute paths go list -e -json ./pkg
func ListPackagePaths ¶ added in v1.1.0
go list ./pkg
func ListRelativeFiles ¶ added in v1.0.51
ListRelativeFiles list all go files, return a list of relative paths go list -e -json ./pkg
func ModCompare ¶ added in v1.0.26
func PkgWithinModule ¶ added in v1.1.0
func ResolveMainModule ¶ added in v1.0.19
ResolveMainModule returns the main module path and subPaths to the directory containing the go.mod file from dir
Types ¶
type GoVersion ¶
func GetGorootVersion ¶ added in v1.1.3
func ParseGoVersion ¶
func ParseGoVersionNumber ¶ added in v1.0.37
ParseGoVersionNumber parses example input: 1.23rc1
type LoadPackageOptions ¶ added in v1.1.0
type LoadPackageOptions struct {
Dir string
Mod string
ModFile string // -modfile flag
Goroot string // GOROOT env
Deps bool // -deps flag
Test bool // -test flag, if true, will have packages like "github.com/xhd2015/xgo/runtime/test/trap/inspect [github.com/xhd2015/xgo/runtime/test/trap/inspect.test]", so don't set it
}
type ModVersion ¶ added in v1.0.26
type Package ¶ added in v1.1.0
type Package struct {
// the abs dir
Dir string
Name string // the package name, e.g. "github.com/x/y/v2" -> y
ImportPath string
// the file names
// e.g.: main.go, option.go
GoFiles []string
TestGoFiles []string
// XTestGoFiles is when a _test.go file
// declares package as xxx_test, while the
// package name of normal file is xxx
XTestGoFiles []string
Goroot bool // is this package in the Go root?
Standard bool // is this package part of the standard Go library?
DepOnly bool // package is only a dependency, not explicitly listed
Incomplete bool // this package or a dependency has an error
Error *PackageError // error loading package
}
check 'go help list'
func ListPackages ¶ added in v1.0.39
func ListPackages(args []string, opts LoadPackageOptions) ([]*Package, error)
go list -e -json ./pkg
type PackageError ¶ added in v1.1.0
type VendorInfo ¶ added in v1.0.26
type VendorInfo struct {
VendorList []ModVersion // modules that contribute packages to the build, in order of appearance
VendorReplaced []ModVersion // all replaced modules; may or may not also contribute packages
VendorVersion map[string]string // module path → selected version (if known)
VendorPkgModule map[string]ModVersion // package → containing module
VendorMeta map[ModVersion]vendorMetadata
// contains filtered or unexported fields
}
func ParseVendor ¶ added in v1.0.26
func ParseVendor(dirOrFile string) (*VendorInfo, error)
ParseVendor reads the list of vendored modules from vendor/modules.txt.
func ParseVendorContent ¶ added in v1.0.26
func ParseVendorContent(content string) *VendorInfo
type Version ¶ added in v1.0.26
type Version struct {
Major string // decimal
Minor string // decimal or ""
Patch string // decimal or ""
Kind string // "", "alpha", "beta", "rc"
Pre string // decimal or ""
}
see: https://cs.opensource.google/go/go/+/master:src/internal/gover/gover.go
func ParseVersion ¶ added in v1.0.26
Click to show internal directories.
Click to hide internal directories.