func createJob(client *beam.Client) *beam.Job { job, err := client.NewJob("tty") if err != nil { panic(err) } master, slave, err := pty.Open() if err != nil { panic(err) } _, err = term.SetRawTerminal(master.Fd()) if err != nil { panic(err) } go job.WriteTo(slave, "stdout") go job.WriteTo(slave, "stderr") go job.ReadFrom(slave, "stdin") go io.Copy(os.Stdout, master) go io.Copy(os.Stderr, master) go io.Copy(master, os.Stdin) return job }
func createJob(client *beam.Client) *beam.Job { job, err := client.NewJob("exec", os.Args[1:]...) if err != nil { panic(err) } job.Env = []string{"DEBUG=1"} go func() { if _, err := io.Copy(os.Stdout, job.Streams.OpenRead("stdout")); err != nil { panic(err) } }() go func() { if _, err := io.Copy(os.Stderr, job.Streams.OpenRead("stderr")); err != nil { panic(err) } }() return job }