github.com/hashicorp/go-getter/v2@v2.2.2/get_file_symlink_windows.go (about) 1 package getter 2 3 import ( 4 "fmt" 5 "os/exec" 6 "path/filepath" 7 "syscall" 8 ) 9 10 func SymlinkAny(oldname, newname string) error { 11 sourcePath := filepath.FromSlash(oldname) 12 13 // Use mklink to create a junction point 14 output, err := exec.Command("cmd", "/c", "mklink", "/J", newname, sourcePath).CombinedOutput() 15 if err != nil { 16 return fmt.Errorf("failed to run mklink %v %v: %v %q", newname, sourcePath, err, output) 17 } 18 return nil 19 } 20 21 var ErrUnauthorized = syscall.ERROR_PRIVILEGE_NOT_HELD