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: go.mod go get does not keep file mode (it breaks symbolic links in package) #28312

Closed
karupanerura opened this issue Oct 22, 2018 · 1 comment

Comments

@karupanerura
Copy link

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

go version go1.11.1 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/karupanerura/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/karupanerura/.go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/karupanerura/project/myapp/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xq/5cs_2lx107bb7thp7qrhw68spwnl58/T/go-build478980627=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I started to use go mod. And import this package: https://github.com/kentaro/go-hoedown
But go get creates broken package files on $GOPATH/mod/github.com/kentaro/go-hoedown@v0.0.0-20181022120212-3beb09ec8bbe.
Because this repository uses symbolic links to import external package's c files and compile it with cgo, but cmd/go/internal/modfetch/unzip ignores file mode.

What did you expect to see?

I think keep file type using zip file (extra) header. I tried following patch:

diff --git a/src/cmd/go/internal/modfetch/unzip.go b/src/cmd/go/internal/modfetch/unzip.go
index a50431fd86..765b68d9f5 100644
--- a/src/cmd/go/internal/modfetch/unzip.go
+++ b/src/cmd/go/internal/modfetch/unzip.go
@@ -113,7 +113,7 @@ func Unzip(dir, zipfile, prefix string, maxSize int64) error {
                if err := os.MkdirAll(filepath.Dir(dst), 0777); err != nil {
                        return err
                }
-               w, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0444)
+               w, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, zf.Mode()&7444) // keep file type and makes read only file
                if err != nil {
                        return fmt.Errorf("unzip %v: %v", zipfile, err)
                }

But, it's not works. (maybe, is it archive/zip's bug?)

What did you see instead?

nop 😢

@karupanerura
Copy link
Author

I have just found it: #24057 (comment)

@golang golang locked and limited conversation to collaborators Oct 22, 2019
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

2 participants