| 28 | } |
| 29 | |
| 30 | func transferDirectoryToRemote(localFilePath string, remoteFilePath string, remoteUser string, remoteHost string) error { |
| 31 | localFile, err := os.Open(localFilePath) |
| 32 | if err != nil { |
| 33 | return fmt.Errorf("failed to open local file: %s", err) |
| 34 | } |
| 35 | defer localFile.Close() |
| 36 | |
| 37 | cmd := exec.Command("scp", "-r", localFilePath, remoteUser+"@"+remoteHost+":"+remoteFilePath) |
| 38 | |
| 39 | err = cmd.Run() |
| 40 | if err != nil { |
| 41 | return fmt.Errorf("file %s transferred to %s@%s:%s failed", localFilePath, remoteUser, remoteHost, remoteFilePath) |
| 42 | } |
| 43 | |
| 44 | log.Printf("file '%s' transferred to '%s@%s:%s' successfully.\n", localFilePath, remoteUser, remoteHost, remoteFilePath) |
| 45 | |
| 46 | return nil |
| 47 | } |
| 48 | |
| 49 | // TODO: to remove unused by golangci |
| 50 | var _ = copyFolder |