Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete a package that I accidentally published to go.dev?

Tags:

go

go-packages

I accidentally published a package to go.dev website, can anyone tell me how to delete it?

https://pkg.go.dev/github.com/Nksama/Random-quotes

like image 874
Yato Avatar asked Dec 22 '22 15:12

Yato


1 Answers

Published modules cannot be deleted but can be retracted. A retracted version still exists and can be downloaded (so builds that depend on it won't break), but the go command won’t select it automatically when resolving. More info here.

To retract you will have to add retract directive to your go.mod. For example

retract v1.0.0
retract [v1.0.0, v1.9.9]
retract (
    v1.0.0
    [v1.0.0, v1.9.9]
)

Please Note :

The retract directive was added in Go 1.16. Go 1.15 and lower will report an error if a retract directive is written in the main module's go.mod file and will ignore retract directives in go.mod files of dependencies.

like image 118
Shailesh Suryawanshi Avatar answered Feb 16 '23 01:02

Shailesh Suryawanshi