valyala / gozstd

go wrapper for zstd
MIT License
421 stars 60 forks source link

Go modules set gozstd directory to 0555, causing "make clean libzstd.a" to fail #6

Open pmer opened 5 years ago

pmer commented 5 years ago

Issue

make clean libzstd.a fails with a file system permission error if using Go modules as implemented in Go 1.11. The make clean target tries to remove the libzstd_target file, but Go has set the current directory to Unix permission 0555, which does not allow removing files.

Specifically:

$ make clean libzstd.a
rm -f libzstd_darwin.a
rm: libzstd_darwin.a: Permission denied
make: *** [clean] Error 1

Seems that with the move to modules, the Go project is taking an aggressive stance on this. Their deciding reason is that this, in particular, prevents unit tests, which are run from their containing directory, from modifying the contents of their directory.

See https://github.com/golang/go/issues/27161.

Expected

Either make clean libzstd.a succeeds or there is some workaround.

Steps to reproduce

Bash script:

export GOPATH=/tmp/go
mkdir $GOPATH
cd $GOPATH
mkdir main
cd main
cat > main.go <<EOF
package main

import "github.com/valyala/gozstd"

func main() {
    dst := make([]byte, 1024)
    src := make([]byte, 1024)
    gozstd.Compress(dst, src)
}
EOF
cat > go.mod <<EOF
module main

require github.com/valyala/gozstd v1.2.1
EOF
go get
cd $GOPATH/pkg/mod/github.com/valyala/gozstd@v1.2.1
make clean libzstd.a
pmer commented 5 years ago

Another situation where files are not writable, albiet for a different reason. This one because the files are owned by a different user.

https://github.com/golang/go/issues/30185