pub struct GoFormatter;Expand description
Formatter for Go module version strings and package URLs.
Handles Go-specific version formatting:
- Versions are unquoted in go.mod (v1.2.3)
- Pseudo-versions (v0.0.0-20191109021931-daa7c04131f5)
- +incompatible suffix for v2+ modules without /v2 path
Trait Implementations§
Source§impl DiagnosticMessages for GoFormatter
impl DiagnosticMessages for GoFormatter
Source§fn yanked_message(&self) -> &'static str
fn yanked_message(&self) -> &'static str
Source§fn yanked_label(&self) -> &'static str
fn yanked_label(&self) -> &'static str
Source§fn deprecated_message(&self) -> &'static str
fn deprecated_message(&self) -> &'static str
Source§fn deprecated_label(&self) -> &'static str
fn deprecated_label(&self) -> &'static str
Source§impl DiagnosticPolicy for GoFormatter
impl DiagnosticPolicy for GoFormatter
Source§fn strict_semver_prerelease_exclusion(&self) -> bool
fn strict_semver_prerelease_exclusion(&self) -> bool
X.Y.Z-pre) is excluded from matching
requirement unless requirement itself pins to the same X.Y.Z tuple with a
pre-release tag — the rule Cargo’s semver crate and npm’s node-semver both
implement, and that compile_requirement’s matcher inherits from its underlying
comparator. Read moreSource§fn supports_package_rename(&self) -> bool
fn supports_package_rename(&self) -> bool
crate::Deprecation::replacement)
is safe to offer as a “Replace with X” rename quickfix. Read moreSource§fn yanked_diagnostic_applies_to(
&self,
_dep: &dyn Dependency,
_requirement: &VersionReq,
) -> bool
fn yanked_diagnostic_applies_to( &self, _dep: &dyn Dependency, _requirement: &VersionReq, ) -> bool
crate::lsp_helpers::requirement_matches_only_yanked) should evaluate requirement
at all for this ecosystem. Read moreSource§impl OsvNaming for GoFormatter
impl OsvNaming for GoFormatter
Source§fn osv_version_to_native(&self, version: &str) -> String
fn osv_version_to_native(&self, version: &str) -> String
crate::osv::Advisory::fixed_versions) into this ecosystem’s
own version namespace, as used in manifests and by the registry. Read moreSource§fn osv_version(&self, version: &str) -> String
fn osv_version(&self, version: &str) -> String
Source§fn osv_package_name(&self, dep: &dyn Dependency) -> Option<String>
fn osv_package_name(&self, dep: &dyn Dependency) -> Option<String>
dep’s package name, or None if
this dependency cannot be mapped (e.g. a non-GitHub Swift package). Read moreSource§impl PackageNaming for GoFormatter
impl PackageNaming for GoFormatter
Source§fn validate_package_name(&self, name: &str) -> Result<(), InvalidPackageName>
fn validate_package_name(&self, name: &str) -> Result<(), InvalidPackageName>
Reuses crate::registry::validate_module_path — the same structural rule that
gates every registry request — so a malformed module path (empty, too long, or
containing a ./.. path segment) is reported as “Invalid package name” instead of
falling through to a registry lookup and rendering the generic “Registry lookup
failed” diagnostic (#402).
§Errors
Returns InvalidPackageName carrying validate_module_path’s rejection reason.
Source§fn normalize_package_name(&self, name: &PackageName) -> String
fn normalize_package_name(&self, name: &PackageName) -> String
Source§impl PackageRendering for GoFormatter
impl PackageRendering for GoFormatter
Source§fn suppress_package_url(&self, source: &DependencySource) -> bool
fn suppress_package_url(&self, source: &DependencySource) -> bool
S4 (spec 034 review): suppresses the pkg.go.dev hover link for anything but a plain
public-registry dependency, reusing SourcePolicy::source_is_public_registry_content’s
default (Registry only — Go has no crates.io-style verified-mirror concept for
AlternateRegistry to except, mirroring deps-pypi’s identical reasoning). Without
this, a GOPRIVATE-matched module’s hover still rendered a clickable
pkg.go.dev/<private-path> link, undermining the confidentiality guarantee FR-008/
NFR-003(2) exist for — the module path never reaches pkg.go.dev over the network
either way (this is a display link only, see crate::registry::package_url’s doc),
but the link itself named the private path in the rendered hover text.
Source§fn format_version_for_text_edit(&self, version: &ConcreteVersion) -> String
fn format_version_for_text_edit(&self, version: &ConcreteVersion) -> String
Source§fn package_url(&self, name: &PackageName) -> String
fn package_url(&self, name: &PackageName) -> String
Source§fn format_version_replacing(
&self,
version: &ConcreteVersion,
_current: &str,
) -> String
fn format_version_replacing( &self, version: &ConcreteVersion, _current: &str, ) -> String
version as a replacement for the existing requirement text
current, preserving current’s operator/pin style where the
ecosystem supports more than one. Read moreSource§fn format_version_replacing_for(
&self,
_dep: &dyn Dependency,
version: &ConcreteVersion,
current: &str,
) -> String
fn format_version_replacing_for( &self, _dep: &dyn Dependency, version: &ConcreteVersion, current: &str, ) -> String
format_version_replacing, but also
carries the dependency identity version/current apply to. Read moreSource§fn is_position_on_dependency(
&self,
dep: &dyn Dependency,
position: Position,
) -> bool
fn is_position_on_dependency( &self, dep: &dyn Dependency, position: Position, ) -> bool
Source§impl RequirementResolution for GoFormatter
impl RequirementResolution for GoFormatter
Source§fn compile_requirement(
&self,
requirement: &VersionReq,
) -> Option<Box<dyn RequirementMatcher>>
fn compile_requirement( &self, requirement: &VersionReq, ) -> Option<Box<dyn RequirementMatcher>>
Compiles requirement into an ExactMatcher using the same exact/pseudo-version
comparison version_satisfies_requirement uses — Go’s requirement syntax has no
separate “loose” vs. “precise” distinction, so both share go_version_matches. Uses
compile_requirement_unless (see that function and
deps_core::lsp_helpers::RequirementResolution::compile_requirement for the shared “undecidable” contract).
The undecidable predicate is crate::version::is_pseudo_version:
proxy.golang.org/<mod>/@v/list — the source of available — never lists
pseudo-versions (they’re derived per-commit, not enumerable), so a pseudo-version pin
can never be found in available even when the exact commit it names is real. A
+incompatible-suffixed tag (not a pseudo-version) is a real entry /@v/list does
return, so it needs no such guard.
Source§fn version_satisfies_requirement(
&self,
version: &ConcreteVersion,
requirement: &str,
) -> bool
fn version_satisfies_requirement( &self, version: &ConcreteVersion, requirement: &str, ) -> bool
Source§fn manifest_requirement_is_resolved_version(&self, dep: &dyn Dependency) -> bool
fn manifest_requirement_is_resolved_version(&self, dep: &dyn Dependency) -> bool
dep’s manifest version-requirement line is itself the exact
version already selected — never a range. Read moreSource§fn is_requirement_up_to_date(
&self,
requirement: &VersionReq,
latest: &ConcreteVersion,
) -> bool
fn is_requirement_up_to_date( &self, requirement: &VersionReq, latest: &ConcreteVersion, ) -> bool
latest, given its declared requirement. Read moreSource§fn requirement_is_unresolved(&self, _requirement: &VersionReq) -> bool
fn requirement_is_unresolved(&self, _requirement: &VersionReq) -> bool
requirement could not be resolved to a concrete version constraint (e.g. an
unexpanded property/variable placeholder rather than a real version or range). Read moreSource§fn requirement_status(
&self,
requirement: &VersionReq,
latest: &ConcreteVersion,
) -> RequirementStatus
fn requirement_status( &self, requirement: &VersionReq, latest: &ConcreteVersion, ) -> RequirementStatus
is_requirement_up_to_date that distinguishes “confirmed up to
date” from “could not be resolved, so we don’t know.” Read moreSource§fn requirement_status_for(
&self,
dep: &dyn Dependency,
requirement: &VersionReq,
latest: &ConcreteVersion,
) -> RequirementStatus
fn requirement_status_for( &self, dep: &dyn Dependency, requirement: &VersionReq, latest: &ConcreteVersion, ) -> RequirementStatus
requirement_status, but also hands the ecosystem
the dependency itself — for an ecosystem whose requirement text alone is ambiguous
between two shapes with different resolution rules, and which already computed the
disambiguating classification once, at parse time, onto the dependency (deps-gitlab-ci’s
PinStyle, #466 review M-c: a bare "1.2" is Partial under its component: pin
grammar but Branch under its simpler project: ref grammar — indistinguishable from
the text alone). Read moreSource§fn requirement_is_undecidable_given_available(
&self,
_requirement: &VersionReq,
_available: &[ConcreteVersion],
) -> bool
fn requirement_is_undecidable_given_available( &self, _requirement: &VersionReq, _available: &[ConcreteVersion], ) -> bool
available in a way indistinguishable from “never published” — and, if so, whether
requirement names a version-space region that specific omission could explain, given
the versions actually observed in available. Read moreSource§impl SourcePolicy for GoFormatter
impl SourcePolicy for GoFormatter
Source§fn can_resolve_source(&self, source: &DependencySource) -> bool
fn can_resolve_source(&self, source: &DependencySource) -> bool
FR-012 (spec 034): accepts Registry (default) and AlternateRegistry (a $GOENV
GOPROXY-chain or GOPRIVATE-bypass resolution) so hover/diagnostics/code-actions
gate correctly; CustomRegistry (FR-009’s fail-closed state, every hop invalid) is
deliberately not accepted — falls through to the default is_version_resolvable() == false, keeping the existing fail-closed gate intact.
Source§fn source_is_public_registry_content(&self, source: &DependencySource) -> bool
fn source_is_public_registry_content(&self, source: &DependencySource) -> bool
source’s content is exactly the default public registry’s — safe to treat
as such for OSV vulnerability scanning, cache-key signature construction, and hover
heading links. Read more