Go模块在从GitHub删除模块仓库后仍然可用。

huangapple go评论77阅读模式
英文:

Go module is usable even after deleting the module repo from GitHub

问题

这种行为是由于你在 GitHub 上删除了仓库,但仍然可以使用模块中的 calc 包。这是因为 Go 模块在首次下载和构建时会将依赖项缓存到本地。即使仓库被删除,缓存的依赖项仍然可用。所以你仍然可以使用 calc 包中的函数。

英文:

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?

答案1

得分: 3

Go模块镜像会保持您的模块可下载。

请参阅下面的常见问题解答。

我从我的存储库中删除了一个错误的发布版本,但它仍然出现在镜像中,我该怎么办?

镜像尽可能地缓存内容,以避免破坏那些依赖于您的软件包的构建。因此,即使该错误的发布版本在源中不可用,它仍然可能在镜像中可用。如果您删除整个存储库,情况也是一样的。我们建议创建一个新版本,并鼓励人们使用该版本。

来源:https://proxy.golang.org/

英文:

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/

huangapple
  • 本文由 发表于 2022年8月27日 21:08:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/73511273.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定