Here is a basic example of using Go APIs:

import "github.com/go-git/go-git/v5"

r, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
    URL:      "https://github.com/go-git/go-git",
    Progress: os.Stdout,
})
go-git has few notable advanced features, one of which is a pluggable storage system, which is similar to Libgit2 backends. The default implementation is in-memory storage, which is very fast.

r, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
    URL: "https://github.com/go-git/go-git",
})
Another advanced use-case includes a fine-tunable HTTP client, such as the one found at https://github.com/go-git/go-git/blob/master/_examples/custom_http/main.go.

customClient := &http.Client{
    Transport: &http.Transport{ // accept any certificate (might be useful for testing)
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    },
    Timeout: 15 * time.Second,  // 15 second timeout
        CheckRedirect: func(req *http.Request, via []*http.Request) error {
        return http.ErrUseLastResponse // don't follow redirect
    },
}

// Override http(s) default protocol to use our custom client
client.InstallProtocol("https", githttp.NewClient(customClient))

// Clone repository using the new client if the protocol is https://
r, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{URL: url})
As soon as you have a Repository instance, you can access information and perform mutations on it:

// retrieves the branch pointed by HEAD
ref, err := r.Head()

// get the commit object, pointed by ref
commit, err := r.CommitObject(ref.Hash())

// retrieves the commit history
history, err := commit.History()

// iterates over the commits and print each
for _, c := range history {
    fmt.Println(c)
}

Recommend

8.4 Customizing Git - An Example Git-Enforced Policy An Example Git-Enforced Policy Client-Side Hooks

8.4 Customizing Git - An Example Git-Enforced Policy An Example Git-Enforced Policy Server-Side Hook Testing It Out

8.4 Customizing Git - An Example Git-Enforced Policy An Example Git-Enforced Policy Server-Side Hook Enforcing a User-Based ACL System

8.4 Customizing Git - An Example Git-Enforced Policy An Example Git-Enforced Policy Server-Side Hook Enforcing a Specific Commit-Message Format

8.4 Customizing Git - An Example Git-Enforced Policy An Example Git-Enforced Policy Server-Side Hook

7.3 Git Tools - Stashing and Cleaning Stashing and Cleaning Cleaning your Working Directory

7.3 Git Tools - Stashing and Cleaning Stashing and Cleaning Creating a Branch from a Stash

7.3 Git Tools - Stashing and Cleaning Stashing and Cleaning Creative Stashing

7.3 Git Tools - Stashing and Cleaning Stashing and Cleaning Stashing Your Work

6.5 GitHub - Scripting GitHub Scripting GitHub Changing the Status of a Pull Request

6.5 GitHub - Scripting GitHub Scripting GitHub Commenting on an Issue

6.5 GitHub - Scripting GitHub Scripting GitHub Basic Usage

6.5 GitHub - Scripting GitHub Scripting GitHub Services and Hooks Hooks

7.5 Git Tools - Searching Searching Git Log Searching Line Log Search

7.5 Git Tools - Searching Searching Git Log Searching

7.5 Git Tools - Searching Searching Git Grep

4.6 Git on the Server - Smart HTTP Smart HTTP

7.1 Git Tools - Revision Selection Revision Selection Commit Ranges Triple Dot

7.1 Git Tools - Revision Selection Revision Selection Commit Ranges Multiple Points

7.1 Git Tools - Revision Selection Revision Selection Commit Ranges Double Dot

7.1 Git Tools - Revision Selection Revision Selection Ancestry References

7.1 Git Tools - Revision Selection Revision Selection RefLog Shortnames

7.1 Git Tools - Revision Selection Revision Selection Branch References

7.1 Git Tools - Revision Selection Revision Selection Short SHA-1

4.5 Git on the Server - Git Daemon Git Daemon

7.2 Git Tools - Interactive Staging Interactive Staging Staging Patches

7.2 Git Tools - Interactive Staging Interactive Staging Staging and Unstaging Files

7.2 Git Tools - Interactive Staging Interactive Staging

7.10 Git Tools - Debugging with Git Debugging with Git Binary Search

7.10 Git Tools - Debugging with Git Debugging with Git File Annotation

2.2 Git Basics - Recording Changes to the Repository Recording Changes to the Repository Moving Files