Publishing and using go module from tarball?

254 views
Skip to first unread message

volf....@gmail.com

unread,
Jan 4, 2020, 12:54:33 PM1/4/20
to golang-nuts
Greetings,

I would like to ask if it is possible to publish go module using tarball and
later on somehow use it. All examples I was able are about using go modules
from some git repository. However, what I would like to do is publish tarball
same way as I would do for C projects (`make dist`) and later on use that from
another go project.

I have no problem to write the `make dist` target, I'm using makefiles already,
publishing the source code is also easy part
(http://example.org/project-1.0.0.tar.xz), but I have no idea how can I import
something like that.

I was trying to find some resources on this but to no avail. So, is this
something that is possible or am I required to use git (or other VCS) for go
projects?

Thank you for any guidance on this topic.

W.

PS: I don't care about hiding the source code, so binary modules and plugins
are probably not what am I looking for.

wgr

unread,
Jan 5, 2020, 12:11:32 AM1/5/20
to volf....@gmail.com, golang-nuts
On 2020-01-04 15:54, volf....@gmail.com wrote:
> Greetings,
>
> I would like to ask if it is possible to publish go module using tarball and
> later on somehow use it. All examples I was able are about using go modules
> from some git repository. However, what I would like to do is publish
> tarball

Would `go mod vendor` then building with `go build -mod=vendor` or
`GOFLAGS=-mod=vendor go build` work for you?

Amnon Baron Cohen

unread,
Jan 5, 2020, 6:02:52 AM1/5/20
to golang-nuts
If you are happy publishing a zip archive rather than a tarball,
then you can server the module download protocol directly.
See https://research.swtch.com/vgo-module#download_protocol

On Sunday, 5 January 2020 05:11:32 UTC, wgr wrote:

volf....@gmail.com

unread,
Jan 5, 2020, 12:34:50 PM1/5/20
to golang-nuts


On Sunday, January 5, 2020 at 11:02:52 AM UTC, Amnon Baron Cohen wrote:
> If you are happy publishing a zip archive rather than a tarball,
> then you can server the module download protocol directly.

That definitely looks interesting and I will try to find some time to look into it
deeper, however testing it locally seems much more difficult then it really
should have been. Go modules tooling does not seem to support http at
all and as for the https I did not find any way to allow use of self-signed
certificate...

But still, it looks like it might be possible so thanks again, I will try to
twist it to work for my use-case.

Thanks :)

W.
Message has been deleted

Amnon Baron Cohen

unread,
Jan 6, 2020, 10:02:25 AM1/6/20
to golang-nuts
> Go modules tooling does not seem to support http at
> all and as for the https I did not find any way to allow use of self-signed
> certificate...

In Go 1.14 (available as in beta) you can set the GOINSECURE env var to allow http download.
https://tip.golang.org/cmd/go/#hdr-Environment_variables


Bryan C. Mills

unread,
Jan 6, 2020, 11:36:22 AM1/6/20
to golang-nuts
See also the golang.org/x/mod/zip package.
Reply all
Reply to author
Forward
0 new messages