git shortlog
从去拿输出,但我撞到了墙。
下面是一个我可以用它来做的工作示例
git log
:
package main
import (
"fmt"
"os"
"os/exec"
)
func main() {
runBasicExample()
}
func runBasicExample() {
cmdOut, err := exec.Command("git", "log").Output()
if err != nil {
fmt.Fprintln(os.Stderr, "There was an error running the git command: ", err)
os.Exit(1)
}
output := string(cmdOut)
fmt.Printf("Output: \n%s\n", output)
}
它给出了预期的输出:
$> go run show-commits.go
Output:
commit 4abb96396c69fa4e604c9739abe338e03705f9d4
Author: TheAndruu
Date: Tue Aug 21 21:55:07 2018 -0400
Updating readme
git短日志
不知为什么。。。我只是不能让它和短日志一起工作。程序又来了,唯一的变化是git命令行:
package main
import (
"fmt"
"os"
"os/exec"
)
func main() {
runBasicExample()
}
func runBasicExample() {
cmdOut, err := exec.Command("git", "shortlog").Output()
if err != nil {
fmt.Fprintln(os.Stderr, "There was an error running the git command: ", err)
os.Exit(1)
}
output := string(cmdOut)
fmt.Printf("Output: \n%s\n", output)
}
$> go run show-commits.go
Output:
我能跑
git短日志
直接从命令行运行,看起来运行良好。检查
docs
有谁能帮我指出我能做什么不同的吗?
谢谢