【发布时间】:2021-06-02 16:49:14
【问题描述】:
Go 中是否有方法来验证 repo 类型字符串实际上是一个实际的 Github repo URL?
我正在运行克隆 repo 的代码,但在我运行 exec.Command("git", "clone", repo) 之前,我想确保 repo 有效。
package utils
import (
"os/exec"
)
//CloneRepo clones a repo lol
func CloneRepo(args []string) {
//repo URL
repo := args[0]
//verify that is an actual github repo URL
//Clones Repo
exec.Command("git", "clone", repo).Run()
}
【问题讨论】:
-
我对您的问题进行了小幅修改,这样它就不会要求包推荐,这会使 Stackoverflow 偏离主题。