1

I was learning go modules so I created a very basic module with an Add() function and published it on GitHub.

The repository was https://github.com/umermasood/nummanip (it throws 404) becaused I deleted the repo from GitHub.

But I am still able to use the calc package from the module.

package main

import (
    "fmt"

    "github.com/umermasood/nummanip/calc"
)

func main() {
    fmt.Println(calc.Add(1, 2))
}

Output:

3

Above code in the Go Playground: https://go.dev/play/p/gMYD6Jirz_n

What is causing this behavior?

  • 4
    It's called cache. – mkopriva Aug 27 '22 at 13:13
  • @mkopriva I deleted the module cache from $GOPATH and the GitHub repo, but I am still able to use it everywhere. Do you mean GitHub has cached my repo even when I have deleted it? – M Umer Masood Aug 27 '22 at 13:16
  • I mean, if I have deleted the GitHub repo, I shouldn't be able to use that package in the Go Playground, right? – M Umer Masood Aug 27 '22 at 13:17
  • 2
    Go playground is a server with it's own cache. I wouldn't be surprised if it did periodical purges or something similar to free up space taken up by unused modules. Basically I wouldn't worry too much about it. But that's just me. – mkopriva Aug 27 '22 at 13:20
  • 6
    The [proxy](https://proxy.golang.org/), through which with the `go` tool downloads modules, also has a cache. See the second-last section in the linked document. And you may be able to speed up the process of removing the module from the cache by publishing a version with a `retract` directive. (also mentioned in the linked document) – mkopriva Aug 27 '22 at 13:37

1 Answers1

3

The Go Module Mirror is keeping your module downloadable.

See the FAQ item below.

I removed a bad release from my repository but it still appears in the mirror, what should I do?

Whenever possible, the mirror aims to cache content in order to avoid breaking builds for people that depend on your package, so this bad release may still be available in the mirror even if it is not available at the origin. The same situation applies if you delete your entire repository. We suggest creating a new version and encouraging people to use that one instead.

Source: https://proxy.golang.org/

Everton
  • 12,589
  • 9
  • 47
  • 59