草庐IT

shell - 在 Golang 中需要交互式输入的测试执行程序

我正在尝试使用fzf在Go代码中。我引用了给出的示例here由作者。当我尝试为该函数编写测试时,它卡住了,因为fzf需要交互式输入。代码:funcwithFilter(commandstring,inputfunc(inio.WriteCloser))[]string{shell:=os.Getenv("SHELL")iflen(shell)==0{shell="sh"}cmd:=exec.Command(shell,"-c",command)cmd.Stderr=os.Stderrin,_:=cmd.StdinPipe()gofunc(){input(in)in.Close()}()

shell - 在 Golang 中需要交互式输入的测试执行程序

我正在尝试使用fzf在Go代码中。我引用了给出的示例here由作者。当我尝试为该函数编写测试时,它卡住了,因为fzf需要交互式输入。代码:funcwithFilter(commandstring,inputfunc(inio.WriteCloser))[]string{shell:=os.Getenv("SHELL")iflen(shell)==0{shell="sh"}cmd:=exec.Command(shell,"-c",command)cmd.Stderr=os.Stderrin,_:=cmd.StdinPipe()gofunc(){input(in)in.Close()}()