### ` _version_`变量在base.go文件中
![QzpcVXNlcnNccGNcQXBwRGF0YVxSb2FtaW5nXERpbmdUYWxrXDE2MTcyMjUxNVxJbWFnZUZpbGVzXEVDQUM5Q0ZDLTg2QUEtNDk1NS05NjUyLUU1OURDRjMxNDkxMS5wbmc=.png](https://static.studygolang.com/180808/c07c69aff541dcbfd336342439bc2ebb.png)
### base.go的详情
![QzpcVXNlcnNccGNcQXBwRGF0YVxSb2FtaW5nXERpbmdUYWxrXDE2MTcyMjUxNVxJbWFnZUZpbGVzXDE3REQ3NzI0LUQ4RDktNDM2ZS1COUQwLTIwMzMyOEU5MjlCRi5wbmc=.png](https://static.studygolang.com/180808/11c226dbc4fe8d77333c97c2bc18b0ea.png)
### 我的编译命令
go build -ldflags "-X `setting/base._version_=v1.0`"
但是运行应用的时候,`_version_`变量没有被赋值。
比如你的`setting`包导入路径为`github.com/wwcd/prj/pkg/setting`,那就是`-X github.com/wwcd/prj/pkg/setting._version_=v1.0`
#3
更多评论
是你参数设置的问题,应该是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