import (
"fmt"
"os/exec"
"strings"
)
func main() {
// Replace with your remote repository URL
remoteURL := "https://github.com/user/repo.git"
// Run the "git remote get-url" command and capture its output
output, err := exec.Command("git", "remote", "get-url", "origin").Output()
if err != nil {
fmt.Println(err)
return
}
// Parse the output to retrieve the remote repository URL
url := strings.TrimSpace(string(output))
fmt.Println("Remote repository URL:", url)
}
Golang 如何得到git repo 的 URL
最新推荐文章于 2024-05-21 22:12:28 发布