1

I'm trying to build a Go program where I have a required library on my system in binary form. However, go build fails with

object is [linux amd64 go1.1.1 X:none] expected [linux amd64 go1.1.2 X:none]

I see what the immediate problem is: the static library was built with an older version of Go. How can I read that information from the .a file directly? (I can see it with strings library.a | grep '^go object', but is there something that's meant to output the build string? (And, what is that string properly called?)

4

1 回答 1

1

Go 编译器生成的.a文件是使用该pack工具管理的。用于链接包的元数据可以在__.PKGDEF存档的成员中找到。

您可以将此文件从存档中提取到stdout

go tool pack p path/to/package.a __.PKGDEF

它从您所追求的构建签名开始,因此您可以使用第一行或 grep^go object的输出strings(这应该更可靠,以防文本在程序中显示为常量代码)。

于 2013-09-22T15:18:21.960 回答