mirror of
https://github.com/golang/go
synced 2024-11-21 16:54:46 -07:00
cmd/go/internal/modload: delete unused files
This commit is contained in:
parent
70491a8111
commit
b82d773317
@ -1,28 +0,0 @@
|
|||||||
// Copyright 2019 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
//go:build (js && wasm) || plan9
|
|
||||||
|
|
||||||
// On plan9, per http://9p.io/magic/man2html/2/access: “Since file permissions
|
|
||||||
// are checked by the server and group information is not known to the client,
|
|
||||||
// access must open the file to check permissions.”
|
|
||||||
//
|
|
||||||
// js,wasm is similar, in that it does not define syscall.Access.
|
|
||||||
|
|
||||||
package modload
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/fs"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
// hasWritePerm reports whether the current user has permission to write to the
|
|
||||||
// file with the given info.
|
|
||||||
func hasWritePerm(path string, _ fs.FileInfo) bool {
|
|
||||||
if f, err := os.OpenFile(path, os.O_WRONLY, 0); err == nil {
|
|
||||||
f.Close()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
// Copyright 2019 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
//go:build unix
|
|
||||||
|
|
||||||
package modload
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/fs"
|
|
||||||
"os"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
// hasWritePerm reports whether the current user has permission to write to the
|
|
||||||
// file with the given info.
|
|
||||||
//
|
|
||||||
// Although the root user on most Unix systems can write to files even without
|
|
||||||
// permission, hasWritePerm reports false if no appropriate permission bit is
|
|
||||||
// set even if the current user is root.
|
|
||||||
func hasWritePerm(path string, fi fs.FileInfo) bool {
|
|
||||||
if os.Getuid() == 0 {
|
|
||||||
// The root user can access any file, but we still want to default to
|
|
||||||
// read-only mode if the go.mod file is marked as globally non-writable.
|
|
||||||
// (If the user really intends not to be in readonly mode, they can
|
|
||||||
// pass -mod=mod explicitly.)
|
|
||||||
return fi.Mode()&0222 != 0
|
|
||||||
}
|
|
||||||
|
|
||||||
const W_OK = 0x2
|
|
||||||
return syscall.Access(path, W_OK) == nil
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
// Copyright 2019 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package modload
|
|
||||||
|
|
||||||
import "io/fs"
|
|
||||||
|
|
||||||
// hasWritePerm reports whether the current user has permission to write to the
|
|
||||||
// file with the given info.
|
|
||||||
func hasWritePerm(_ string, fi fs.FileInfo) bool {
|
|
||||||
// Windows has a read-only attribute independent of ACLs, so use that to
|
|
||||||
// determine whether the file is intended to be overwritten.
|
|
||||||
//
|
|
||||||
// Per https://golang.org/pkg/os/#Chmod:
|
|
||||||
// “On Windows, only the 0200 bit (owner writable) of mode is used; it
|
|
||||||
// controls whether the file's read-only attribute is set or cleared.”
|
|
||||||
return fi.Mode()&0200 != 0
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user