1package main
2
3import (
4 "os"
5
6 "github.com/go-git/go-git/v5"
7 . "github.com/go-git/go-git/v5/_examples"
8)
9
10// Example of how to show the progress when you do a basic clone operation.
11func main() {
12 CheckArgs("<url>", "<directory>")
13 url := os.Args[1]
14 directory := os.Args[2]
15
16 // Clone the given repository to the given directory
17 Info("git clone %s %s", url, directory)
18
19 _, err := git.PlainClone(directory, false, &git.CloneOptions{
20 URL: url,
21 Depth: 1,
22
23 // as git does, when you make a clone, pull or some other operations the
24 // server sends information via the sideband, this information can being
25 // collected providing a io.Writer to the CloneOptions options
26 Progress: os.Stdout,
27 })
28
29 CheckIfError(err)
30}