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.
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.
Yes, but it could be in any file.
Also, I don't understand why it prints the message and cycle twice.
@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.
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.
Most helpful comment
@ianlancetaylor
It be nice to have
file:linein the error message.Instead of
I'd propose
I can implement this if you guys like the idea.