client_golang icon indicating copy to clipboard operation
client_golang copied to clipboard

Installing examples is not working anymore

Open itsmylife opened this issue 3 years ago • 3 comments

I am trying to install the examples with the command below:

$ go install github.com/prometheus/client_golang/examples/random@latest

but I am getting the following error:

go: github.com/prometheus/client_golang/examples/random@latest (in github.com/prometheus/[email protected]):
	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.

This was working with the previous version:

go install github.com/prometheus/client_golang/examples/[email protected]

I assume the changes introduced here https://github.com/prometheus/client_golang/pull/1062 are the reason. Especially this line: https://github.com/prometheus/client_golang/blob/main/go.mod#L31

My Go Version:

go version go1.18.1 darwin/arm64

itsmylife avatar Aug 18 '22 21:08 itsmylife

Maybe we need the examples to use their own go.mod? But that might lead to weird situations…

Or we can reconsider the exclude directive? IIRC it was only added to silence buggy security scanners (that would be confused by the dependency resolution method of Go Modules when faced with circular dependencies).

beorn7 avatar Aug 23 '22 12:08 beorn7

Both the strategies make sense. With the new Go workspace features having different modules in a project should be rather easier. Also, we might already have deprecated the need for the exclude, if I'm not mistaken we have bumped the minimum required Go version since then. And the issue was related to the older Go version. (I might misremembering things).

kakkoyun avatar Aug 24 '22 05:08 kakkoyun

I've started taking a look at this issue to see if I can help.

  1. I'm pretty new to workspaces. Should go.work be committed, or should I add an entry to .gitignore?
  2. After I've made my changes how do I validate that I've solved the original issue?

Dean-Coakley avatar Sep 27 '22 11:09 Dean-Coakley

Hello 👋 Looks like there was no activity on this issue for the last 3 months. Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗 If there will be no activity in the next 4 weeks, this issue will be closed (we can always reopen an issue if we need!).

stale[bot] avatar Apr 02 '23 13:04 stale[bot]

Closing for now as promised, let us know if you need this to be reopened! 🤗

stale[bot] avatar Sep 17 '23 06:09 stale[bot]