I'm having a problem using Ubuntu 14.04 and executing diff
on the command line. Look at the following Go code:
package main
import "fmt"
import "log"
import "os/exec"
func main() {
output, err := exec.Command("diff", "-u", "/tmp/revision-1", "/tmp/revision-4").Output()
if err != nil {
log.Fatalln(err)
}
fmt.Println(string(output))
}
If i execute this using go run test.go
i get the following error:
2015/03/18 14:39:25 exit status 1
exit status 1
So something is going wrong with diff
and it's returning 1
as its exit code. Only the diff
command seems to throw an error. If i use the cat
or wc
command, the code runs fine.
Any ideas why diff
doesn't work here but other commands do?