[英]Run perl from golang
I want to utilize perl from my golang application for regexp purposes.我想将我的 golang 应用程序中的 perl 用于正则表达式。 How can I run a perl file and communicate between the two processes?
如何运行 perl 文件并在两个进程之间进行通信? I have tried the package
os/exec
but it gave me a pointer as a final value.我试过包
os/exec
但它给了我一个指针作为最终值。
I do not think it to be not a good idea to use os/exec
just to use regex.我认为使用
os/exec
只是为了使用正则表达式并不是一个好主意。 But if you absolutely need to.但如果你绝对需要。 Run it through
os/exec
command and then read it from Cmd.Stdout
and Cmd.Stderr
.通过
os/exec
命令运行它,然后从Cmd.Stdout
和Cmd.Stderr
读取它。 For providing inputs you can use Cmd.Stdin
.要提供输入,您可以使用
Cmd.Stdin
。
You are getting pointer may be because you are not running the command.您正在获取指针可能是因为您没有运行该命令。 Is that how you are trying
c :=exec.Command('perl')
Also run c.Run()
这就是你尝试的方式
c :=exec.Command('perl')
也运行c.Run()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.