Skip to content

go.mod: remove obsolete exclude rule - #2077

Merged
bwplotka merged 1 commit into
prometheus:mainfrom
thaJeztah:drop_exclude
Aug 18, 2026
Merged

bwplotka merged 1 commit into
prometheus:mainfrom
thaJeztah:drop_exclude

Conversation

@thaJeztah

Copy link
Copy Markdown
Contributor

relates to;

The exclude was originally added in 02fec46 to prevent traversing client_golang v1.12.1. No current dependency requires that version, making the exclude obsolete.

To verify;

go list -m all

which produced no changes.

Also verified that:

go mod tidy
go test ./...

produce no changes and all tests pass.

The exclude was originally added in 02fec46
to prevent traversing client_golang v1.12.1. No current dependency requires
that version, making the exclude obsolete.

To verify;

    go list -m all

which produced no changes.

Also verified that:

    go mod tidy
    go test ./...

produce no changes and all tests pass.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@bwplotka

Copy link
Copy Markdown
Member

Thanks. What's the motivation for this change? Just cleanup?

No current dependency requires that version, making the exclude obsolete.

It's more about users who should skip this version, when updating client_golang in the past as it was broken. Not sure why go list -m all would help figuring out if anyone else still imports e..g 1.11 and won't upgrade to a broken version.

Still, it's unlikely given time, but is there harm leaving?

@thaJeztah

Copy link
Copy Markdown
Contributor Author

Hi! Thanks for looking!

What's the motivation for this change? Just cleanup?

Yes, cleanup because it's no longer needed, but also because it partially breaks the module (I'll post an example).

It's more about users who should skip this version, when updating client_golang in the past as it was broken.

The exclude won't help with that; exclude helps preventing the module's own "requires" to skip the version (so that go.mod doesn't use it), and helps during version resolution, but for users of the module, it has no effect; https://go.dev/doc/modules/gomod-ref#exclude

Use the exclude and replace directives to control build-time dependency resolution when building the current module. These directives are ignored in modules that depend on the current module.

But .. I found some time ago that, despite the documentation mentioning the directives are "ignored", they do have an effect, and make the module partially broken, because go install will refuse instaling if it finds an exclude rule;

go install github.com/prometheus/client_golang/examples/simple@latest
go: github.com/prometheus/client_golang/examples/simple@latest (in github.com/prometheus/client_golang@v1.24.1):
	The go.mod file for the module providing named packages contains one or
	more exclude directives. It must not contain directives that would cause
	it to be interpreted differently than if it were the main module.

Not sure why go list -m all would help figuring out if anyone else still imports e..g 1.11 and won't upgrade to a broken version.

The go list was used to check that the module itself no longer had the broken version in its graph (so to check if the exclude was still relevant); it does indeed not show if any user of the module would have it, but (as mentioned above), the exclude won't help with that.

@thaJeztah

Copy link
Copy Markdown
Contributor Author

It's more about users who should skip this version, when updating client_golang in the past as it was broken

Actually; in case I misunderstood the intent; was client_golang v1.12.1 itself broken? Because if that's the case, then probably the correct thing is to retract the version (i.e., mark that version as "faulty release; do not use")
https://go.dev/doc/modules/gomod-ref#retract

e.g.;

retract v1.12.1 // Broken release, do not use.

I don't think that prevents users from installing it, but at least will provide the correct metadata, pkg.go.dev will show it as retracted;

Screenshot 2026-08-18 at 13 35 04

@bwplotka bwplotka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you are right I mixed exclude with retract -- TIL that breaks install (but not go run).

Let's do this, thanks!

@bwplotka
bwplotka merged commit 56b1a27 into prometheus:main Aug 18, 2026
15 checks passed
@thaJeztah

Copy link
Copy Markdown
Contributor Author

TIL that breaks install (but not go run).

Same for me (well not Today but some time ago); I thought exclude was "local" so no side-effect for consumers.. Then ran into that error.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants