pub fn escape_version(version: &str) -> StringExpand description
Escapes a Go version string for safe interpolation into proxy.golang.org
@v/{version}.info and @v/{version}.mod URLs.
Mirrors escape_module_path’s case-encoding convention: uppercase letters
become ! + lowercase (the Go module-proxy case-folding rule), since a raw
uppercase version segment — legal in a semver prerelease identifier such as
v1.7.0-RC — otherwise 404s against the proxy. Every other character
outside [a-z0-9.+-] is percent-encoded, preventing ?, #, or
whitespace from being interpreted as URL syntax (starting a query string
or fragment) instead of literal version content.
§Examples
use deps_go::escape_version;
assert_eq!(escape_version("v1.9.1"), "v1.9.1");
assert_eq!(escape_version("v2.0.0+incompatible"), "v2.0.0+incompatible");
assert_eq!(escape_version("v1.7.0-RC"), "v1.7.0-!r!c");
assert_eq!(escape_version("v1?a=b"), "v1%3Fa%3Db");