3

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

blackgreen
  • 34,072
  • 23
  • 111
  • 129
Yato
  • 103
  • 1
  • 11
  • On top of the retract answers, go proxies will cache a package, even after the repo has been deleted. So as you've probably learned already, be very careful what you publish to the internet. – colm.anseo Jul 31 '21 at 16:54

2 Answers2

8

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.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
1

There's package removal guide on the site: https://go.dev/about/

Basically you need to put retract directive in your go.mod file and publish new version.

blami
  • 6,588
  • 2
  • 23
  • 31