go - 使用所需模块的旧版本编译 go 源代码
问题描述
我试图构建一个go
需要的源代码,go-systemd
我在源包中看到go.mod 文件go-systemd
中也提到了该版本。github.com/coreos/go-systemd/v22 v22.0.0
但是当我运行go get -u
源代码时。它失败并出现错误,我看到在v22.2.0
.
pkg/mod/github.com/coreos/go-systemd/v22@v22.2.0/sdjournal/journal.go:1160:2: could not determine kind of name for C.my_sd_id128_to_string
cgo:
gcc errors for preamble:
pkg/mod/github.com/coreos/go-systemd/v22@v22.2.0/sdjournal/journal.go:313:60: error: '_SD_ARRAY_STATIC' undeclared here (not in a function)
// my_sd_id128_to_string(void *f, sd_id128_t boot_id, char s[_SD_ARRAY_STATIC SD_ID128_STRING_MAX])
^
In file included from /usr/include/systemd/sd-journal.h:31:0,
from pkg/mod/github.com/coreos/go-systemd/v22@v22.2.0/sdjournal/journal.go:27:
pkg/mod/github.com/coreos/go-systemd/v22@v22.2.0/sdjournal/journal.go:313:77: error: expected ']' before numeric constant
// my_sd_id128_to_string(void *f, sd_id128_t boot_id, char s[_SD_ARRAY_STATIC SD_ID128_STRING_MAX])
我应该如何使用以前没有此代码的版本来避免此错误?我正在go version 1.16
使用centos7
提前致谢。
解决方案
推荐阅读
- javascript - 居中对齐位于 javascript 中的图像
- javascript - JS的展开语法是否出现在其他语言中?
- angular - FileSaver.saveAs 不是角度 2 中的函数
- ms-access - 如何将组合框视为另一个表单的链接?
- matlab - 引导 Matlab 中的颜色
- html - 如何摆脱(之后)标题和导航之间的小空间?
- php - 如何将 URL 后缀添加到自定义路由?
- java - [Ljava.lang.Object; 不能转换为 [Ljava.lang.String;
- android - 无法在测试和 QA 环境中使用 GCM 获取设备令牌
- java - 有没有办法从“本机”java应用程序调用gwt方法