details for "import cycle not allowed"?

1,230 views
Skip to first unread message

stephanos

unread,
Aug 26, 2013, 10:48:09 AM8/26/13
to golan...@googlegroups.com
Hi there,

I just ran into a compiler error: init.go: import cycle not allowed
Obviously I've done something wrong.

But the message only shows half of the problem, init.go.
It would be interesting to see the other involved file(s), wouldn't it?

Cheers
Stephan

Ian Lance Taylor

unread,
Aug 26, 2013, 11:00:53 AM8/26/13
to stephanos, golang-nuts
Yes, and you normally should. What version of Go are you using? Do
you have a simple test case?

Ian

stephanos

unread,
Aug 26, 2013, 11:32:03 AM8/26/13
to golan...@googlegroups.com, stephanos
Well, I was just about to prepare a test case when I stumbled upon something.

I created a simple 3-file-project with package A and B which depend on another.
When I executed go build it showed the warning as described above: init.go:3:8: import cycle not allowed

But when I prepared the sample for GitHub and adding the proper package path this happended:

So perhaps this only works for full-path'ed packages?


Regards
Stephan

Ian Lance Taylor

unread,
Aug 26, 2013, 12:44:05 PM8/26/13
to stephanos, golang-nuts
On Mon, Aug 26, 2013 at 8:32 AM, stephanos <stephan...@gmail.com> wrote:
> Well, I was just about to prepare a test case when I stumbled upon
> something.
>
> I created a simple 3-file-project with package A and B which depend on
> another.
> When I executed go build it showed the warning as described above:
> init.go:3:8: import cycle not allowed
>
> But when I prepared the sample for GitHub and adding the proper package path
> this happended:
> package github.com/stephanos/go_import_cycle/pckg_a
> imports github.com/stephanos/go_import_cycle/pckg_b
> imports github.com/stephanos/go_import_cycle/pckg_a: import cycle not
> allowed
>
> So perhaps this only works for full-path'ed packages?
>
> PS: https://github.com/stephanos/go_import_cycle /
> https://github.com/stephanos/go_import_cycle_local


Thanks for the test case.

http://golang.org/issue/6254

Ian

Rob Pike

unread,
Aug 26, 2013, 5:37:29 PM8/26/13
to Ian Lance Taylor, stephanos, golang-nuts
Just last week I fixed the go command to print the import cycle, so if
you were using Go at tip you would have seen a description of the
cycle.

-rob

atkaaz

unread,
Aug 26, 2013, 5:42:27 PM8/26/13
to golang-nuts



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ian Lance Taylor

unread,
Aug 26, 2013, 7:19:13 PM8/26/13
to Rob Pike, stephanos, golang-nuts
Bother, sorry about that.

Ian
Reply all
Reply to author
Forward
0 new messages