golang, how to execute command which requires input from user
From the os/exec.Command docs:
// Stdin specifies the process's standard input. If Stdin is
// nil, the process reads from the null device (os.DevNull).
Stdin io.Reader
Set the command's Stdin field before executing it.
// To run any system commands. EX: Cloud Foundry CLI commands: `CF login`
cmd := exec.Command("cf", "login")
// Sets standard output to cmd.stdout writer
cmd.Stdout = os.Stdout
// Sets standard input to cmd.stdin reader
cmd.Stdin = os.Stdin
cmd.Run()