1 回答

TA貢獻1797條經驗 獲得超6個贊
這應該有效:
package main
import (
"os"
"fmt"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/go-git/go-git/v5/storage/memory"
git "github.com/go-git/go-git/v5"
)
func main() {
token := "ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
fs := memfs.New()
_, err := git.Clone(memory.NewStorage(), fs, &git.CloneOptions{
URL: "https://github.com/username/reponame",
ReferenceName: plumbing.ReferenceName("refs/heads/main"),
Depth: 1,
SingleBranch: true,
Auth: &http.BasicAuth{Username: "username", Password: token},
Progress: os.Stdout,
})
if err != nil {
fmt.Println(err)
}
fmt.Println("Done")
}
- 1 回答
- 0 關注
- 138 瀏覽
添加回答
舉報