logo
  • 教程列表
  • SO官方文檔
  • 執行命令
    • 用中斷定時然後殺死
    • 執行命令然後繼續並等待
    • 簡單的命令執行
    • 兩次執行命令
  1. StackOverflow 文件
  2. Go 教程
  3. 執行命令
  4. 簡單的命令執行

簡單的命令執行

Created: November-22, 2018

// Execute a command a capture standard out. exec.Command creates the command
// and then the chained Output method gets standard out. Use CombinedOutput() 
// if you want both standard out and standerr output
out, err := exec.Command("echo", "foo").Output()
if err != nil {
    log.Fatal(err)
}
  • 兩次執行命令
  • 執行命令然後繼續並等待

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明