You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: