Binary only package stub file

111 views
Skip to first unread message

Aakash das

unread,
Jan 28, 2019, 4:56:39 PM1/28/19
to golan...@googlegroups.com
Hello everyone,
The requirements for binary only source file has changed in Go 1.10. Could you please guide me to the steps that are needed for making binary only package work with Go 1.10. I couldn't find any example on generating a stub source '.go' file with dependencies explicitly specified.
Thanks and Regards,
Aakash

Ian Lance Taylor

unread,
Jan 28, 2019, 5:29:25 PM1/28/19
to Aakash das, golang-nuts
On Mon, Jan 28, 2019 at 1:56 PM Aakash das <aakas...@gmail.com> wrote:
>
> Hello everyone,
> The requirements for binary only source file has changed in Go 1.10. Could you please guide me to the steps that are needed for making binary only package work with Go 1.10. I couldn't find any example on generating a stub source '.go' file with dependencies explicitly specified.

Write a Go file that looks like

//go:binary-only-package

func packagename

import (
"first/dependency"
"second/dependency"
)

Note that after the 1.12 release, binary-only packages will no longer
be supported.

Ian

Aakash das

unread,
Jan 29, 2019, 2:54:03 AM1/29/19
to Ian Lance Taylor, golan...@googlegroups.com
+golang-nuts.

On Tue, Jan 29, 2019 at 1:20 PM Aakash das <aakas...@gmail.com> wrote:
Thanks for the reply, Ian. I have an additional question. Given a Go binary package file in '.a' format, would it be possible to extract dependencies for the said binary package using some tool?  My end goal is to automate the generation of the stub file for binary-only packages provided by the vendors. 
Regards,
Aakash

Ian Lance Taylor

unread,
Jan 29, 2019, 9:50:13 AM1/29/19
to Aakash das, golang-nuts
On Mon, Jan 28, 2019 at 11:53 PM Aakash das <aakas...@gmail.com> wrote:
>
> +golang-nuts.
>
> On Tue, Jan 29, 2019 at 1:20 PM Aakash das <aakas...@gmail.com> wrote:
>>
>> Thanks for the reply, Ian. I have an additional question. Given a Go binary package file in '.a' format, would it be possible to extract dependencies for the said binary package using some tool? My end goal is to automate the generation of the stub file for binary-only packages provided by the vendors.

I think It is possible. I think that if you run `go tool nm` on the
.a file, you will see undefined references to PKG.init. That should
give you the list of imported packages. I'm not completely sure if
every imported package will be listed reliably in that way, though.

Ian
Reply all
Reply to author
Forward
0 new messages