I accidentally published a package to go.dev website, can anyone tell me how to delete it?
            Asked
            
        
        
            Active
            
        
            Viewed 1,383 times
        
    3
            
            
        - 
                    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 Answers
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
 
        Shailesh Suryawanshi
        
- 1,190
 - 7
 - 12
 
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