Skip to content

fix: local replace will produce invalid require #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025

Conversation

jizhuozhi
Copy link
Contributor

@jizhuozhi jizhuozhi commented Apr 22, 2025

What type of PR is this?

A bug fix

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

replace本地路径时将会产生无效的require

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
When using local relation path to replace deps, the parser will replace the deps directly, and then version of deps will be empty (cause not dep@version formated).

Here is the invalid go.mod content with testdata in repo

module a.b/c/cmdx

go 1.24.2

require (
	a.b/c
	github.com/bytedance/sonic v1.11.3
	github.com/pkg/errors v0.9.1
)

but follow is expected

module a.b/c/cmdx

go 1.24.2

require (
	a.b/c v0.0.0
	github.com/bytedance/sonic v1.11.3
	github.com/pkg/errors v0.9.1
)

require (
	github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
	github.com/chenzhuoyu/iasm v0.9.0 // indirect
	github.com/klauspost/cpuid/v2 v2.0.9 // indirect
	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
	golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
)

replace a.b/c => ../.

zh(optional):
当go.mod文件中存在相对路径的replace时,require将会丢失version产生无效的go.mod文件,导致go mod tidy失败

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

@welkeyever welkeyever requested a review from AsterDY April 23, 2025 03:45
@AsterDY AsterDY merged commit 8544a9d into cloudwego:main Apr 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants