如何使用GO中的“ os / exec”包将文件从一个目录复制到另一个目录

if I am in directory A and running the GO code, and I need to copy a file from directory B to directory C , how to do it? I tried adding cmd.Dir = "B" but it can copy the files in "B" directory, but when I try full path for directory "C" it throws error "exit status 1"

basic code sample

Currently in directory A with location "/var/A" cmd := exec.Command("cp","/var/C/c.txt","/var/B/") err := cmd.Run()

"os/exec" is the Go package used to run external programs, which would include Linux utilities.

// The command name is the first arg, subsequent args are the
// command arguments.
cmd := exec.Command("tr", "a-z", "A-Z")
// Provide an io.Reader to use as standard input (optional)
cmd.Stdin = strings.NewReader("some input")
// And a writer for standard output (also optional)
var out bytes.Buffer
cmd.Stdout = &out
// Run the command and wait for it to finish (the are other
// methods that allow you to launch without waiting.
err := cmd.Run()
if err != nil {
    log.Fatal(err)
}
fmt.Printf("in all caps: %q
", out.String())