I want to execute
cat database_dump_1.sql | docker exec -i my_postgres psql -U postgres
using exec.Command method of Golang.
My code goes like this :
options := []string{"out.sql", "|", "docker", "exec", "-i", "my_postgres", "psql", "-U", "postgres"}
cmd, err := exec.Command("cat", options...).Output()
if err != nil {
panic(err)
}
fmt.Println(string(cmd))
but this fails. I guess I am not able to escape "|". I have tried "\|", but this also fails. What am I doing wrong??