Help us shape the future of Go! Take the 2026 Go Developer Survey

versions

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CompatibilityCheckExitCode = 3
)

Variables

View Source
var (
	ErrGoCmdNotFound                   = errors.New("go cmd not found")
	ErrGoModNotFound                   = errors.New("go.mod file not found in current directory or any parent directory")
	ErrDependencyNotFound              = errors.New("dependency not found")
	ErrDependencyVersionNotCompatible  = errors.New("dependency not compatible")
	ErrDependencyVersionNotSemantic    = errors.New("dependency version is not semantic version")
	ErrDependencyReplacedWithLocalRepo = errors.New("dependency replaced with local repo")
)

Functions

func DefaultCheckDependencyAndProcess

func DefaultCheckDependencyAndProcess() error

DefaultCheckDependencyAndProcess provided default processing procedure to parse CheckResult and prompt users

func RegisterMinDepVersion

func RegisterMinDepVersion(depVer *MinDepVersion) error

RegisterMinDepVersion registers Minimal Dependency Version to be checked

Types

type CheckResult

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

func CheckDependency

func CheckDependency() *CheckResult

CheckDependency is responsible for checking the compatibility of dependency and return the checking results. After calling CheckDependencies(), you should check if the result is Nil:

res := CheckDependency()
if res != nil {
}

If res is not nil, pls check the related error with `Err()`:

	if err := res.Err(); err != nil {
	    switch {
        case errors.Is(err, ErrGoCmdNotFound):
        case errors.Is(err, ErrGoModNotFound):
	    case errors.Is(err, ErrDependencyNotFound):
	    case errors.Is(err, ErrDependencyVersionNotSemantic):
	    case errors.Is(err, ErrDependencyReplacedWithLocalRepo):
	    case errors.Is(err, ErrDependencyVersionNotCompatible):
	    }
	}

Then you can get the version in go.mod with `GoModVersion()` and retrieve the MinDepVersion information with `MinDepVersion()`.

func (*CheckResult) Err

func (cr *CheckResult) Err() error

Err returns the error in checking process

func (*CheckResult) GoModVersion

func (cr *CheckResult) GoModVersion() string

GoModVersion returns the version of the dependency in the go.mod

func (*CheckResult) MinDepVersion

func (cr *CheckResult) MinDepVersion() *MinDepVersion

type MinDepVersion

type MinDepVersion struct {
	// RefPath is the reference path to the dependency
	// e.g. github.com/cloudwego/kitex
	RefPath string
	// Version is the minimal required version
	Version string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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