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

cmd/go: include files and lines in import-cycle errors #12871

Closed
willfaught opened this issue Oct 7, 2015 · 6 comments
Closed

cmd/go: include files and lines in import-cycle errors #12871

willfaught opened this issue Oct 7, 2015 · 6 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@willfaught
Copy link
Contributor

The error can be more helpful if it pinpoints the files/lines that cause the cycle.

Example:

$ go build
can't load package: import cycle not allowed
package foo
    imports foo
import cycle not allowed
package foo
    imports foo

That could be anywhere in foo.

@ianlancetaylor
Copy link
Contributor

I think it's a fine idea, but the cycle can't be anywhere in foo: it has to be an import statement, and import statements have to be near the start of a file.

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Oct 7, 2015
@willfaught
Copy link
Contributor Author

Yes, but it could be in any file.

@willfaught
Copy link
Contributor Author

Also, I don't understand why it prints the message and cycle twice.

@VojtechVitek
Copy link

VojtechVitek commented Nov 9, 2016

@ianlancetaylor

It be nice to have file:line in the error message.

Instead of

import cycle not allowed
package github.com/pressly/api/cmd/api
        imports github.com/pressly/api
        imports github.com/pressly/api/data
        imports github.com/pressly/api/data/presenter
        imports github.com/pressly/api/data

I'd propose

import cycle not allowed
package github.com/pressly/api/cmd/api
        imports github.com/pressly/api
                at cmd/main.go:12
        imports github.com/pressly/api/data
                at api.go:8
        imports github.com/pressly/api/data/presenter
                at data/user.go:14
        imports github.com/pressly/api/data
                at data/presenter/user.go:6

I can implement this if you guys like the idea.

@ianlancetaylor
Copy link
Contributor

Sure, though I would keep it on line ("imports github.com/pressly/api at cmd/main.go:12"). It's too late for Go 1.8 but please send a CL for Go 1.9.

@bcmills bcmills changed the title cmd/go: Import cycle build error can be more helpful cmd/go: include files and lines in import-cycle errors Jan 23, 2019
@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 23, 2019
@willfaught
Copy link
Contributor Author

No activity. Closing.

@willfaught willfaught closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2022
@golang golang locked and limited conversation to collaborators Nov 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants