1 # Regression test for golang.org/issue/34634: permissions for the go.sum and
2 # go.mod files should be preserved when overwriting them.
3
4 env GO111MODULE=on
5 [short] skip
6
7 # Skip platforms that do not have Unix-style file permissions.
8 [GOOS:windows] skip
9 [GOOS:plan9] skip
10
11 chmod 0640 go.mod
12 chmod 0604 go.sum
13 go mod edit -module=golang.org/issue/34634
14
15 go get
16 cmp go.mod go.mod.want
17 cmp go.sum go.sum.want
18
19 go run .
20 stdout 'go.mod: 0640'
21 stdout 'go.sum: 0604'
22
23 -- read_perm.go --
24 package main
25
26 import (
27 "fmt"
28 "os"
29 _ "rsc.io/sampler"
30 )
31
32 func main() {
33 for _, name := range []string{"go.mod", "go.sum"} {
34 fi, err := os.Stat(name)
35 if err != nil {
36 fmt.Fprintf(os.Stderr, "%s: %v\n", err)
37 continue
38 }
39 fmt.Printf("%s: 0%o\n", name, fi.Mode().Perm())
40 }
41 }
42 -- go.mod --
43 module TODO
44
45 go 1.14
46 -- go.sum --
47 -- go.mod.want --
48 module golang.org/issue/34634
49
50 go 1.14
51
52 require rsc.io/sampler v1.99.99
53 -- go.sum.want --
54 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw=
55 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
56 rsc.io/sampler v1.99.99 h1:iMG9lbEG/8MdeR4lgL+Q8IcwbLNw7ijW7fTiK8Miqts=
57 rsc.io/sampler v1.99.99/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
58
View as plain text