MCPcopy Index your code
hub / github.com/jetify-com/devbox / ParseVersionedPackage

Function ParseVersionedPackage

internal/searcher/parse.go:12–27  ·  view source on GitHub ↗

ParseVersionedPackage checks if the given package is a versioned package (`python@3.10`) and returns its name and version

(versionedName string)

Source from the content-addressed store, hash-verified

10// ParseVersionedPackage checks if the given package is a versioned package
11// (`python@3.10`) and returns its name and version
12func ParseVersionedPackage(versionedName string) (name, version string, found bool) {
13 // use the last @ symbol as the version delimiter, some packages have @ in the name
14 atSymbolIndex := strings.LastIndex(versionedName, "@")
15 if atSymbolIndex == -1 {
16 return "", "", false
17 }
18 if atSymbolIndex == len(versionedName)-1 {
19 // This case handles packages that end with `@` in the name
20 // example: `emacsPackages.@`
21 return "", "", false
22 }
23
24 // Common case: package@version
25 name, version = versionedName[:atSymbolIndex], versionedName[atSymbolIndex+1:]
26 return name, version, true
27}

Callers 10

ResolveMethod · 0.92
searchCmdFunction · 0.92
SyncLockfilesFunction · 0.92
ResolveMethod · 0.92
IsLegacyPackageFunction · 0.92
FetchResolvedPackageMethod · 0.92
InfoMethod · 0.92
updatePendingPackagesMethod · 0.92
parseVersionedNameFunction · 0.92

Calls

no outgoing calls

Tested by 2

ResolveMethod · 0.74