☄️ How to update version's cache of your package in pkg.go.dev?
Tags: go, tutorial, beginners, fiber
Published: 2020-07-06 11:56:27

## Introduction

Hi, DEV people! 😉 Sometimes, when you publish a new version of your Go package, [pkg.go.dev](https://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! 👌

<a name="toc"></a>
### 📝 Table of contents

- [A little story from real-life](#ch-1)
- [Solution](#ch-2)

<a name="ch-1"></a>
## A little story from real-life

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

{% github gofiber/fiber no-readme %}

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](#toc)

<a name="ch-2"></a>
## Solution

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

```Makefile
# ...

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

# ...
```

And use it, like this:

```bash
make update-pkg-cache USER=gofiber PACKAGE=fiber VERSION=1.12.4
```

> 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](#toc)

<a name=""></a>
## P.S.

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

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 projects that need your help (and stars) 👇

- 🔥 [gowebly][gowebly_url]: A next-generation CLI tool for easily build amazing web applications with Go on the backend, using htmx & hyperscript and the most popular atomic/utility-first CSS frameworks on the frontend.
- ✨ [create-go-app][cgapp_url]: Create a new production-ready project with Go backend, frontend and deploy automation by running one CLI command.
- 🏃 [yatr][yatr_url]: Yet Another Task Runner allows you to organize and automate your routine operations that you normally do in Makefile (or else) for each project.
- 📚 [gosl][gosl_url]: The Go Snippet Library provides snippets collection for working with routine operations in your Go programs with a super user-friendly API and the most efficient performance.
- 🏄‍♂️ [csv2api][csv2api_url]: The parser reads the CSV file with the raw data, filters the records, identifies fields to be changed, and sends a request to update the data to the specified endpoint of your REST API.
- 🚴 [json2csv][json2csv_url]: The parser can read given folder with JSON files, filtering and qualifying input data with intent & stop words dictionaries and save results to CSV files by given chunk size.

<!-- Footer links -->

[gowebly_url]: https://github.com/gowebly
[cgapp_url]: https://github.com/create-go-app
[yatr_url]: https://github.com/koddr/yatr
[gosl_url]: https://github.com/koddr/gosl
[csv2api_url]: https://github.com/koddr/csv2api
[json2csv_url]: https://github.com/koddr/json2csv