Skip to content

Instantly share code, notes, and snippets.

@moisoto
Last active January 25, 2021 18:40
Show Gist options
  • Save moisoto/200f77ce57085f94490e5f2136a3148e to your computer and use it in GitHub Desktop.
Save moisoto/200f77ce57085f94490e5f2136a3148e to your computer and use it in GitHub Desktop.
Publishing Your Package Documentation

Publishing your Package

Go Module!

If you haven't already go and initialize your module:

# This assumes you have your package located at ~/go/src/github.com/your_account/your_package
go mod init github.com/your_account/your_package
go mod tidy

This will create the following files:

go.sum
go.mod

If you have a remote then is best to commit this and push it:

git add go.mod go.sum
git commit -m "Initialize Go Module."
git push

Tag your version

You can tag your package version using the git tag command:

git tag -a v1.0.0 -m "Version 1.0.0"

To see your tag information:

# Just the Tags
git tag -n

# More detailed info
git show v1.0.0

Push the tag to ORIGIN:

git push origin v1.0.0

If you want to undo your tag for some reason:

git tag -d v1.0.0
git push --delete origin v1.0.0

Add Version Badge

It's recommended that you put a badge in your README.md to let users know what's the latest release:

[![Release](https://img.shields.io/github/v/tag/your_user/your_repo?label=Release&sort=semver)](https://github.com/your_user/your_repo/releases/latest)

Check and Refresh your public documentation

First go to proxy.golang.org and fech your new version info:

https://proxy.golang.org/github.com/your_user/your_repo/@v/v1.0.0.info

Then check that the documentation was refreshed. If not, try to load the specific version and a Resquest button will be provided for you to do a manual fetch:

https://pkg.go.dev/github.com/your_user/your_repo/@v1.0.0

Some useful links:

Basic Tagging

How to Crate Git Tags

How to Delete Local and Remore Tags on Git

About Go.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment