Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to publish a Go package

Tags:

go

I am trying to publish my Go package so it is visible on doc search and go search, and can be installed with go get.

However, the one document I found doesn't clearly tell me how to get the documentation generated and hosted, or to publish the package at all. How can I publish my package?

like image 779
dylhunn Avatar asked May 01 '17 09:05

dylhunn


2 Answers

For publishing go modules to public URL and make it visible and downloadable at https://pkg.go.dev/:

First, upload your package to a public URL which must have a license for your package in your case it is

github.com/dylhunn/dragontoothmg

After this assign a tag to your package source and push it to GitHub for details see https://golang.org/doc/modules/publishing

git tag v0.1.0
git push origin v0.1.0

Your package will not be searchable immediately until you explicitly tell the golang proxy server for updating their index using the below command

GOPROXY=proxy.golang.org go list -m github.com/<github_user_name>/<module_name>@v0.1.0

In your case, it will be

GOPROXY=proxy.golang.org go list -m github.com/dylhunn/[email protected]
like image 154
Zubair Hassan Avatar answered Oct 12 '22 15:10

Zubair Hassan


You already did it.

All you must do to "publish" a Go package is make it available via a public URL. By putting it on GitHub, you have already published your package. You can view the GoDoc as proof. It may take time for the doc search to update, but once you've loaded the GoDoc once on your own, the indexing will happen automatically.

As for Go search, just click the Add Packages link at the top of the page.

like image 37
Flimzy Avatar answered Oct 12 '22 14:10

Flimzy