utils

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package utils: Common functions supporting depbump package management Provides semantic version comparison, Go version matching checks, and workspace iteration Implements standard Go module version comparison logic with pseudo-version support Enables efficient package analysis, toolchain matching validation, and recursive module processing

utils: depbump 包管理的通用工具函数 提供语义版本比较、Go 版本匹配检查和工作区遍历 实现官方 Go 模块版本比较逻辑,支持伪版本 用于高效的包分析、工具链匹配验证和递归模块处理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanUseGoVersion

func CanUseGoVersion(required, target string) bool

CanUseGoVersion checks if a package's Go version requirement is satisfied Returns true when required <= target (required version is compatible with target) Missing required version is treated as compatible (returns true) Accepts plain Go versions (e.g., 1.22, 1.22.8) from go.mod files Uses standard go/version.Compare to enable accurate toolchain version comparison

CanUseGoVersion 检查包的 Go 版本要求是否满足 当 required <= target 时返回 true(需求版本与目标兼容) 缺失的需求版本视作兼容(返回 true) 接受纯数字格式的 Go 版本(如 1.22, 1.22.8)来自 go.mod 文件 使用标准 go/version.Compare 进行准确的工具链版本比较

func CompareVersions

func CompareVersions(v1, v2 string) int

CompareVersions compares package version strings using semver Returns -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2 Expects versions with "v" prefix (e.g., v1.2.3) from go list -m -versions output

CompareVersions 使用 semver 比较包版本字符串 如果 v1 < v2 返回 -1,v1 == v2 返回 0,v1 > v2 返回 1 期望带 "v" 前缀的版本(如 v1.2.3)来自 go list -m -versions 输出

func ForeachModule added in v0.0.32

func ForeachModule(execConfig *osexec.ExecConfig, fn func(*osexec.ExecConfig))

ForeachModule iterates over workspace modules and executes callback Scans workspace using workspath configuration and processes each module

ForeachModule 遍历工作区模块并执行回调 使用 workspath 配置扫描工作区并处理每个模块

func IsStableVersion added in v0.0.26

func IsStableVersion(version string) bool

IsStableVersion checks if a package version is a stable release Returns true when version is valid semver without prerelease and +incompatible suffixes Filters out versions like v2.0.0-preview.4, v1.0.0-rc1, v1.0.0+incompatible Expects version string with "v" prefix from go list -m -versions output

IsStableVersion 检查包版本是否是稳定发布版本 对没有预发布后缀和 +incompatible 标记的有效 semver 版本返回 true 过滤掉如 v2.0.0-preview.4, v1.0.0-rc1, v1.0.0+incompatible 等版本 期望带 "v" 前缀的版本字符串来自 go list -m -versions 输出

func UIProgress added in v0.0.32

func UIProgress(idx, cnt int) string

UIProgress formats progress display as "(<current>/total)" with 1-based index Example: UIProgress(0, 10) returns "(<1>/10)"

UIProgress 格式化进度显示,使用 1-based 索引 示例:UIProgress(0, 10) 返回 "(<1>/10)"

Types

This section is empty.

Jump to

Keyboard shortcuts

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