Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Replace the legacy string wrapper with a canonical comparable URI value. This keeps map keys aligned with the encoded transport form while preserving zero runtime dependencies and pinned vscode-uri vectors. Rejected: preserving parse-history casing in comparable URI fields. Constraint: component accessors expose canonical reparse semantics.
Document the canonical-reparse contract, migration path, vector regeneration workflow, and benchmark evidence so downstream users can review the breaking rewrite without relying on hidden assumptions.
Preserve direct URI string conversions while keeping canonical constructor behavior and the clean file/FsPath allocation gates. Rejected: cached struct metadata; it breaks requested URI string representation.
Document component-specific escaping so callers know which constructor outputs are safe for LSP wire text and where raw syntax is preserved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This branch replaces the previous
net/url-backed implementation ofgo.lsp.dev/uriwith a canonicalvscode-uri-compatible parser and formatter, optimized for the LSP hot path. It also migrates CI/tooling (CircleCI -> GitHub Actions, golangci-lint v2) and adds a reproducible benchmark + conformance-vector harness.This is an intentional behavior rewrite with breaking API changes. See
docs/migration.mdfor the full migration guide.Motivation
The old
New/Filename/From(scheme, ...)surface mixed URI parsing with filesystem fallback (os.Getwd,filepath.Abs,runtime.GOROOT) and could emit invalid URIs. The rewrite aligns Go identity semantics with VSCode'svscode-uriso thatfile://SERVER/x==file://server/xandfile:///C:/x==file:///c%3A/xcompare equal and are safe as native Go==and map keys.Breaking API changes
New(string)Parse(string)(URI text) orFile(string)(filesystem path)Filename()FsPath()/FsPathFor(URI, Platform, bool)From(scheme, authority, path, query, fragment)From(Components)FileScheme,HTTPScheme,HTTPSSchemeScheme(),IsFile()Key behavioral differences:
Parsefollowsvscode-urinon-strict parsing (empty-scheme falls back tofile);ParseStrictrequires a scheme and returns typed sentinel errors.File/FileFornever touch the filesystem; relative-looking input is encoded as provided.URI.parse(input).toString().type URI stringis preserved, so directURI("...")conversions still compile — but they do not validate or canonicalize. Prefer constructors for new values.Design: string-backed canonical values
The public representation stays
type URI string. Equality and map keys are free native==;String()is a 2-cost inlinable conversion. Component accessors (Path,Authority, ...) split the canonical string on demand rather than caching per-value offsets, keeping the hot path allocation-free.Performance
Headline numbers (Apple M3 Max, darwin/arm64, go1.26.4,
GOEXPERIMENTunset). Full evidence + reproduction indocs/perf.md.Parse("file:///.../main.go")FsPathForclean POSIX file URIString()FileForclean absolute pathnet/urlstring baselineParse("https://host/p?name=ferret#f")Known gaps (documented, not regressions)
Tooling / CI
ubuntu-slim+ubuntu-24.04-arm), Codecov via OIDC, lint via golangci-lint v2.vscode-uridependency (tools/genvectors).testdata/corpus/uri_bench.tsvwithnet/urlcomparison scaffolding, fuzz tests, and alloc tests.Verification
go build ./...— cleango vet ./...— cleango test ./...— PASS