gpt4 book ai didi

go - 不允许导入周期

转载 作者:IT老高 更新时间:2023-10-28 12:57:24 26 4
gpt4 key购买 nike

我有问题

import cycle not allowed

它在我尝试测试我的 Controller 时出现。这是输出:

can't load package: import cycle not allowed
package project/controllers/account
imports project/controllers/base
imports project/components/mux
imports project/controllers/account
import cycle not allowed
package project/controllers/account
imports project/controllers/base
imports project/components/mux
imports project/controllers/account
import cycle not allowed
package project/controllers/account
imports project/controllers/base
imports project/components/mux
imports project/controllers/routes
imports project/controllers/base

如何阅读或理解此错误?依赖错在哪里?

最佳答案

这是您的第一个导入周期问题的说明。

                  project/controllers/account
^ \
/ \
/ \
/ \/
project/components/mux <--- project/controllers/base


正如您在我的错误 ASCII 图表中看到的那样,当 project/components/mux 导入 project/controllers/account 时,您正在创建一个导入周期。由于 Go 不支持循环依赖,因此在编译时会出现 import cycle not allowed 错误。

关于go - 不允许导入周期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28256923/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com