'What if the package imported in go mod is deleted? [duplicate]

My team use some open source libraries on Github, and they are worried about github packages being deleted, such as for political reasons.

So we use both go mod and vendor, use vendor to cache code.(if no vendor, CI/CD will download/build failed when library has been deleted.)

I don't want to keep the vendor, but there is no way to avoid the library being deleted.

go


Solution 1:[1]

Golang is a compiled program and you don't need to check the version of the imported package. When you download the package for the first time it will be cached in your system. and until you change the version of the package it will use the latest cache.

When the repository is deleted, your go mod file cant find the repository and it says not found. so you need to change it or replace it.

The first solution I can say now is you can fork the main repository and use the forked repository in your go.mod file.

but I think you are strict about this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ttrasn