☄️ How to update version's cache of your package in pkg.go.dev?

Vic Shóstak - Jul 6 '20 - - Dev Community

Introduction

Hi, DEV people! 😉 Sometimes, when you publish a new version of your Go package, pkg.go.dev may still give away an old version for a long time.

This also means, that if other people are using your package, not be able to update to the new version until the cache is updated.

Let's fix this! 👌

📝 Table of contents

A little story from real-life

That's what we did at Fiber Go web framework a few months ago.

GitHub logo gofiber / fiber

⚡️ Express inspired web framework written in Go

After fixed a major bug, a new Fiber version could not be installed on users projects for about a couple of hours, because the cache was not updated. But the press release for the fix was already out (in official repository, Twitter, etc.) and users wanted to update and could not.

Worst-case scenario, isn't it? 😨

↑ Table of contents

Solution

Save this command to a Makefile (or a task manager you're using now):

# ...

update-pkg-cache:
    GOPROXY=https://proxy.golang.org GO111MODULE=on \
    go get github.com/$(USER)/$(PACKAGE)@v$(VERSION)

# ...
Enter fullscreen mode Exit fullscreen mode

And use it, like this:

make update-pkg-cache USER=gofiber PACKAGE=fiber VERSION=1.12.4
Enter fullscreen mode Exit fullscreen mode

Where:

  • USER your GitHub user or organization name
  • PACKAGE a name of your package to update cache
  • VERSION a version number to update cache

It's that simple and clear!

↑ Table of contents

P.S.

If you want more articles (like this) on this blog, then post a comment below and subscribe to me. Thanks! 😻

❗️ You can support me on Boosty, both on a permanent and on a one-time basis. All proceeds from this way will go to support my OSS projects and will energize me to create new products and articles for the community.

support me on Boosty

And of course, you can help me make developers' lives even better! Just connect to one of my projects as a contributor. It's easy!

My main projects that need your help (and stars) 👇

  • 🔥 gowebly: A next-generation CLI tool that makes it easy to create amazing web applications with Go on the backend, using htmx, hyperscript or Alpine.js and the most popular CSS frameworks on the frontend.
  • create-go-app: Create a new production-ready project with Go backend, frontend and deploy automation by running one CLI command.

Other my small projects: yatr, gosl, json2csv, csv2api.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player