Documentation
¶
Index ¶
- func CapitalizeFirst(s string) string
- func ExtractSemverVersion(version string) string
- func MergeStringSlicePointers(slices ...*[]string) *[]string
- func MergeStructs(dst interface{}, srcs ...interface{})
- func ParsePackageWithVersion(versions []string) map[string]string
- func RemoveDuplicates[T comparable](sliceList []T) []T
- func StandardizeJSON(b []byte) ([]byte, error)
- type Semver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CapitalizeFirst ¶
CapitalizeFirst converts the first character of a string to uppercase. The rest of the string remains unchanged. Examples:
- "hello" -> "Hello"
- "world" -> "World"
- "" -> ""
- "already Capitalized" -> "Already Capitalized"
func ExtractSemverVersion ¶
ExtractSemverVersion extracts the first version number found in a string. It supports full semver (major.minor.patch) as well as partial versions (major or major.minor). The version can appear anywhere in the string and can have prefixes or suffixes. Examples:
- "1.2.3" -> "1.2.3"
- "v1.2.3" -> "1.2.3"
- "python-3.10.7" -> "3.10.7"
- "version1.2.3-beta" -> "1.2.3"
- "requires node 14.2" -> "14.2"
- "python 3" -> "3"
Returns an empty string if no version number is found.
func MergeStringSlicePointers ¶
MergeStringSlicePointers combines multiple string slice pointers, deduplicates values, and sorts them
func MergeStructs ¶
func MergeStructs(dst interface{}, srcs ...interface{})
MergeStructs merges multiple structs of the same type, with later values taking precedence. Only non-zero values from later structs will override earlier values.
func ParsePackageWithVersion ¶
ParsePackageWithVersion parses a slice of package specifications in the format "name@version" and returns a map of package names to their versions. If a package has no version specified (no @ symbol), it defaults to "latest". Examples:
- ["node@14.2"] -> {"node": "14.2"}
- ["python"] -> {"python": "latest"}
- ["ruby@3.0.0", "go"] -> {"ruby": "3.0.0", "go": "latest"}
- ["node@^14.3", "python@>=3.9"] -> {"node": "^14.3", "python": ">=3.9"}
func RemoveDuplicates ¶
func RemoveDuplicates[T comparable](sliceList []T) []T
func StandardizeJSON ¶ added in v0.6.0
convert hujson/extended JSON into standardized json