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

cmd/go: be more selective about removes #2829

Closed
peterGo opened this issue Feb 1, 2012 · 2 comments
Closed

cmd/go: be more selective about removes #2829

peterGo opened this issue Feb 1, 2012 · 2 comments
Milestone

Comments

@peterGo
Copy link
Contributor

peterGo commented Feb 1, 2012

A directory contains a Go source file (toy.go) and a directory (toy) which contains a
file (toy.data).

~/gopath/src
    toy.go
~/gopath/src/toy
    toy.data

$ pwd
/home/peter/gopath/src
$ ls
toy  toy.go
$ cd toy
$ pwd
/home/peter/gopath/src/toy
$ ls
toy.data
$ 

The `go build toy.go` command fails because it tries to write a file named toy which
collides with the non-empty directory named toy.

$ pwd
/home/peter/gopath/src
$ go build toy.go
open toy: is a directory
$ 

If toy is a file or an empty directory, it is overwritten.

linux, 386, hg id 1a7e26c156b8 tip.
@rsc
Copy link
Contributor

rsc commented Feb 2, 2012

Comment 1:

go clean is going to smash the same things.
In the old naming, if you had an important file
named a.out it would get removed or overwritten
at will too.
The go tool relies heavily on convention.  If you
violate those conventions, then it becomes less
useful, sometimes actively harmful.
go build toy.go writing 'toy' is definitely the right
default.  If it overwrites an important file named
toy, well, it did what it was told.
However, the remove check should be a little more
careful: it should not remove read-only files and
should also not remove directories.  It is even possible
that we should read the first few bytes from the file
and make sure it is an executable.

Labels changed: added priority-go1, removed priority-triage.

Owner changed to builder@golang.org.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Feb 14, 2012

Comment 2:

This issue was closed by revision 9f33317.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@rsc rsc removed the priority-go1 label Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants