GO語言"os/exec"包中"Cmd.Output"類型的用法及代碼示例。
用法:
func(c *Cmd) Output()([]byte, error)
輸出運行命令並返回其標準輸出。任何返回的錯誤通常都是 *ExitError 類型。如果 c.Stderr 為 nil,則輸出填充 ExitError Stderr。
例子:
package main
import (
"fmt"
"log"
"os/exec"
)
func main() {
out, err := exec.Command("date").Output()
if err != nil {
log.Fatal(err)
}
fmt.Printf("The date is %s\n", out)
}
相關用法
- GO Cmd.Start用法及代碼示例
- GO Cmd.StdinPipe用法及代碼示例
- GO Cmd.StderrPipe用法及代碼示例
- GO Cmd.Run用法及代碼示例
- GO Cmd.StdoutPipe用法及代碼示例
- GO Cmd.CombinedOutput用法及代碼示例
- GO Chmod用法及代碼示例
- GO CanBackquote用法及代碼示例
- GO CopyN用法及代碼示例
- GO CopyBuffer用法及代碼示例
- GO CreateTemp用法及代碼示例
- GO Cut用法及代碼示例
- GO CIDRMask用法及代碼示例
- GO ContainsRune用法及代碼示例
- GO Cbrt用法及代碼示例
- GO Copysign用法及代碼示例
- GO Compare用法及代碼示例
- GO Cosh用法及代碼示例
- GO Config用法及代碼示例
- GO Count用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Cmd.Output。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。