mirror of
https://github.com/gomods/athens
synced 2026-02-03 08:40:31 +00:00
* feat: add golangci-lint linting * chore: fix linter issues * feat: add linting into the workflow * docs: update lint docs * fix: cr suggestions * fix: remove old formatting and vetting scripts * fix: add docker make target * fix: action go caching * fix: depreciated actions checkout version * fix: cr suggestion * fix: cr suggestions --------- Co-authored-by: Manu Gupta <manugupt1@gmail.com>
32 lines
831 B
Go
32 lines
831 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
// PackageVersionedName return package full name used in storage.
|
|
// E.g athens/@v/v1.0.mod.
|
|
func PackageVersionedName(module, version, ext string) string {
|
|
return fmt.Sprintf("%s/@v/%s.%s", module, version, ext)
|
|
}
|
|
|
|
// FmtModVer is a helper function that can take
|
|
// pkg/a/b and v2.3.1 and returns pkg/a/b@v2.3.1.
|
|
func FmtModVer(mod, ver string) string {
|
|
return fmt.Sprintf("%s@%s", mod, ver)
|
|
}
|
|
|
|
// ModuleVersionFromPath returns module and version from a
|
|
// storage path.
|
|
// E.g athens/@v/v1.0.info -> athens and v.1.0.
|
|
func ModuleVersionFromPath(path string) (string, string) {
|
|
segments := strings.Split(path, "/@v/")
|
|
if len(segments) != 2 {
|
|
return "", ""
|
|
}
|
|
version := strings.TrimSuffix(segments[1], filepath.Ext(segments[1]))
|
|
return segments[0], version
|
|
}
|