20

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?

dylhunn
  • 989
  • 2
  • 8
  • 25

2 Answers2

35

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.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
  • 1
    @tonix I don't understand your question, but it doesn't really seem related to this answer. If you still are confused, maybe a separate question would be a good idea. – Jonathan Hall Aug 26 '21 at 08:44
18

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/dragontoothmg@v0.1.0
Zubair Hassan
  • 776
  • 6
  • 14