github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/not-internal/modload/stat_openfile.go (about) 1 // Copyright 2019 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build aix js,wasm plan9 6 7 // On plan9, per http://9p.io/magic/man2html/2/access: “Since file permissions 8 // are checked by the server and group information is not known to the client, 9 // access must open the file to check permissions.” 10 // 11 // aix and js,wasm are similar, in that they do not define syscall.Access. 12 13 package modload 14 15 import ( 16 "os" 17 ) 18 19 // hasWritePerm reports whether the current user has permission to write to the 20 // file with the given info. 21 func hasWritePerm(path string, _ os.FileInfo) bool { 22 if f, err := os.OpenFile(path, os.O_WRONLY, 0); err == nil { 23 f.Close() 24 return true 25 } 26 return false 27 }