Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: Remove/RemoveAll should remove read-only folders on Windows #26295

Nnnes opened this issue Jul 9, 2018 · 3 comments


None yet
5 participants
Copy link

commented Jul 9, 2018

What version of Go are you using (go version)?

go version go1.10.2 windows/amd64

Does this issue reproduce with the latest release?

Untested, but I don't see any changes that would have fixed it

What operating system and processor architecture are you using (go env)?


What did you do?

package main

import (

func main() {
	err := os.RemoveAll("./folder_with_icon")
	if err != nil {

folder_with_icon is an empty folder that has had a custom icon added via Windows Explorer's interface (Properties => Customize => Change Icon...).

What did you expect to see?

folder_with_icon should be deleted.

What did you see instead?

panic: remove ./folder_with_icon: Access is denied.

goroutine 1 [running]:
        C:/[path]/test.go:10 +0x6a


This is similar to #9606.

Setting a custom folder icon on Windows sets the read-only attribute on the folder and creates a desktop.ini file with the system attribute inside the folder. Despite being read-only, the folder can be deleted both through File Explorer and by rd /s folder_with_icon by its owner, even if the owner is not an administrator account. The above Go program will not delete the folder, even if it is run with administrator privileges.

os.RemoveAll() removes the desktop.ini but does not delete the folder.


This comment has been minimized.

Copy link

commented Jul 9, 2018

By analogy with #9606 it seems that we should do this.


This comment has been minimized.

Copy link

commented Jul 20, 2018

I'm working on it


This comment has been minimized.

Copy link

commented Jul 20, 2018

Change mentions this issue: os: remove read-only directories

@ianlancetaylor ianlancetaylor modified the milestones: Go1.12, Go1.13 Dec 20, 2018

@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.