[英]Importing a constants file in go
我的 go 模块中有这个 package 结构,我正在使用 cobra-cli 添加命令:
.
├── LICENSE
├── cmd
│ ├── constants.go
│ ├── root.go
│ └── tools
│ └── tools.go
├── go.mod
├── go.sum
└── main.go
在tools.go
中,我想导入constants.go
,我想为模块中所有文件的全局使用常量定义它,并且很简单 Z34D1F91FB2E514B8576FAB1A75A89A6
package cmd
const (
FOO = "https://a.b.c"
BAR = "https://p.q.r"
)
我如何导入这个? 还有更好的方法吗?
import cycle not allowed
when you used constant.go
inside tools.go
and used tools.go
inside constant.go
, and create a cycle call each other, please check you code import cycle not allowed
when you used constant.go
inside tools.go
和用过tools.go
里面的constant.go
,并创建一个循环调用对方,请检查你的代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.