Fix v2.0.0 main.go importing v1 library path (option 1 from #90)#91
Open
veggiemonk wants to merge 2 commits into
Open
Fix v2.0.0 main.go importing v1 library path (option 1 from #90)#91veggiemonk wants to merge 2 commits into
veggiemonk wants to merge 2 commits into
Conversation
main.go imported "github.com/campoy/embedmd/embedmd" (v1 path) while go.mod declared the module as github.com/campoy/embedmd/v2. As a result, the v2.0.0 binary executes the v1 library code, and any consumer that adds embedmd v2 as a Go tool pulls in both module versions transitively. Switch the import to "github.com/campoy/embedmd/v2/embedmd" so the v2 binary uses its own library copy. main.go's three Process call sites are updated to pass context.Background() to match the v2 Process signature added in this branch. Fixes campoy#90.
The v2 branch added a context.Context parameter to Process but the in-package test never updated its call site, so the embedmd test package failed to compile. Add context.Background() to match the v2 Process signature.
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.
Implements option 1 from #90: fix
main.goand retag.Problem
On the
v2branch,go.moddeclares the module asgithub.com/campoy/embedmd/v2, butmain.goimports the v1 library path:So the v2.0.0 binary actually executes v1 library code, and any consumer adding embedmd v2 as a Go tool pulls in both module versions transitively. Full repro and analysis in #90.
Changes
main.go— change the import togithub.com/campoy/embedmd/v2/embedmd. The threeembedmd.Process(...)call sites now passcontext.Background()to match the v2Processsignature (the context parameter added in commit f18280f, which is what bumped the module to v2 in the first place).embedmd/embedmd_test.go— same context fix. The in-package test never had itsProcesscall updated when the signature changed, sogo test ./...couldn't even compile on this branch. Splitting it into a separate commit keeps the cmd vs library fixes independent.Verification
Known pre-existing issue (not addressed here)
TestProcess/embedding_code_from_a_bad_URLstill fails after this PR:This is a
net/urlerror-format change in newer Go versions (URLs are now quoted inparseerrors). Independent of #90 and predates this PR — happy to send a separate fix if you'd like.Suggested follow-up
After merge, tag
v2.0.1. Existing v2.0.0 consumers update once and the dual-version dependency disappears.