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 ¶
Click to show internal directories.
Click to hide internal directories.