Skip to content
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

Go workspace support from Go 1.18 #3

Closed
gnuletik opened this issue Apr 25, 2022 · 6 comments
Closed

Go workspace support from Go 1.18 #3

gnuletik opened this issue Apr 25, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@gnuletik
Copy link

gnuletik commented Apr 25, 2022

Here is a repo to reproduce

git clone https://github.com/gnuletik/gomoddirectives-repro
cd gomoddirectives-repro/
bash -c 'cd hello && golangci-lint cache clean && golangci-lint run --config ../.golangci-lint.yml'

It should show a warning:

WARN [linters context] running gomoddirectives failed: failed to get module file: unmarshaling error: invalid character '{' after top-level value: {
	"Path": "example.com/hello",
	"Main": true,
	"Dir": "/tmp/gomoddirectives-repro/hello",
	"GoMod": "/tmp/gomoddirectives-repro/hello/go.mod",
	"GoVersion": "1.18"
}
{
	"Path": "example.com/pkg",
	"Main": true,
	"Dir": "/tmp/gomoddirectives-repro/pkg",
	"GoMod": "/tmp/gomoddirectives-repro/pkg/go.mod",
	"GoVersion": "1.18"
}
: if you are not using go modules it is suggested to disable this linter

see golangci/golangci-lint#2752

@ldez ldez self-assigned this Apr 25, 2022
@ldez
Copy link
Owner

ldez commented Apr 25, 2022

Hello,

can you run the following command: go list -m -json

@gnuletik
Copy link
Author

Thanks for the fast feedback!

There you go

$ go list -m -json
{
	"Path": "example.com/hello",
	"Main": true,
	"Dir": "/tmp/gomoddirectives-repro/hello",
	"GoMod": "/tmp/gomoddirectives-repro/hello/go.mod",
	"GoVersion": "1.18"
}
{
	"Path": "example.com/pkg",
	"Main": true,
	"Dir": "/tmp/gomoddirectives-repro/pkg",
	"GoMod": "/tmp/gomoddirectives-repro/pkg/go.mod",
	"GoVersion": "1.18"
}

@ldez
Copy link
Owner

ldez commented Apr 25, 2022

can you do a go mod tidy in the hello repo?

@gnuletik
Copy link
Author

No I can't. It doesn't work because the modules are not published on fetchable URL, see golang/go#50750

$ go mod tidy
go: finding module for package example.com/pkg
example.com/hello imports
	example.com/pkg: cannot find module providing package example.com/pkg: unrecognized import path "example.com/pkg": reading https://example.com/pkg?go-get=1: 404 Not Found

@ldez ldez added the bug Something isn't working label Apr 25, 2022
@ldez
Copy link
Owner

ldez commented Apr 25, 2022

Fixed by 3ce9a65

@ldez ldez closed this as completed Apr 25, 2022
@gnuletik
Copy link
Author

Works like a charm, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants