You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: stat_unix.go
    path of file: ./repos/under-the-hood/gosrc/cmd/go/internal/modload
    
    the code of the file until where you have to start completion: // 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.

// +build darwin dragonfly freebsd linux netbsd openbsd solaris

package modload

import (
	"os"
	"syscall"
)

// hasWritePerm reports whether the current user has pe
    
func hasWritePerm(path string, fi os.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
}