github.com/cli/cli@v1.14.1-0.20210902173923-1af6a669e342/pkg/cmd/extension/symlink_windows.go (about)

     1  package extension
     2  
     3  import "os"
     4  
     5  func makeSymlink(oldname, newname string) error {
     6  	// Create a regular file that contains the location of the directory where to find this extension. We
     7  	// avoid relying on symlinks because creating them on Windows requires administrator privileges.
     8  	f, err := os.OpenFile(newname, os.O_WRONLY|os.O_CREATE, 0644)
     9  	if err != nil {
    10  		return err
    11  	}
    12  	defer f.Close()
    13  	_, err = f.WriteString(oldname)
    14  	return err
    15  }