<p>How can i run multiple and concat commands in go? Is there a way to do that with the exec lib?</p>
<hr/>**评论:**<br/><br/>rjik: <pre><p>You can just use plain os/exec and pipe commands by setting (*exec.Cmd).Std* fields. There are also higher level wrappers like <a href="https://labix.org/pipe" rel="nofollow">https://labix.org/pipe</a>.</p></pre>nathj07: <pre><p>I wonder what the desired outcome is a there may be a better approach available. Are you able to outline what you want to achieve?</p></pre>cs-guy: <pre><p><a href="http://labix.org/pipe" rel="nofollow">http://labix.org/pipe</a></p></pre>DongerDave: <pre><p>Your question shows that you shouldn't be trusted to run commands because you clearly don't understand what they are or how they work.</p>
<p>You can run multiple commands by using <code>exec.Command</code> multiple times.</p>
<p>You can <code>&&</code> or <code>;</code> or <code>|</code> commands together (the former two of those are not command things, but shell things) by doing an exec.Command of something like <code>sh -c "my command && my other command || my third command; my final command"</code>. The go stdlibrary already can do piping with some difficulty.</p>
<p>Next time, consider googling or thinking for 5 seconds before spamming up a forum.</p></pre>eriken: <pre><p>What are you talking about? ofcource you can exec concurrently just have them write to the same channel.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传