Skip to content

fix: local replace will produce invalid require#17

Merged
AsterDY merged 1 commit into
cloudwego:mainfrom
jizhuozhi:main
Apr 27, 2025
Merged

fix: local replace will produce invalid require#17
AsterDY merged 1 commit into
cloudwego:mainfrom
jizhuozhi:main

Conversation

@jizhuozhi
Copy link
Copy Markdown
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
simuleite pushed a commit to simuleite/abcoder that referenced this pull request Feb 28, 2026
* feat: Export entire repo

* fmt

* feat: add `TypeKind` to seprate typedef with struct

* sperator inlined sub struct

* fix: use real method's receiver type to store identi
simuleite pushed a commit to simuleite/abcoder that referenced this pull request Feb 28, 2026
simuleite pushed a commit to simuleite/abcoder that referenced this pull request Mar 2, 2026
* feat: Export entire repo

* fmt

* feat: add `TypeKind` to seprate typedef with struct

* sperator inlined sub struct

* fix: use real method's receiver type to store identi
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