go build -ldflags "-X setting/base._version_=v1.0"编译_version_变量获取不到

EddieChan1993 · · 676 次点击
我就是路径,但是路径不对,应该怎么填这个路径。
#2
更多评论
是你参数设置的问题,应该是importpath,你setting导入包路径+._version_ ``` -X importpath.name=value Set the value of the string variable in importpath named name to value. Note that before Go 1.5 this option took two separate arguments. Now it takes one argument split on the first = sign. ```
#1
比如你的`setting`包导入路径为`github.com/wwcd/prj/pkg/setting`,那就是`-X github.com/wwcd/prj/pkg/setting._version_=v1.0`
#3