# README
go-gitexec
Thin wrapper to execute git commands in Go.
Usage
Basic Usage
import (
"fmt"
"strings"
"github.com/thombashi/go-gitexec"
)
func ExampleRunGit() {
executor, err := gitexec.New(&gitexec.Params{})
if err != nil {
panic(err)
}
result, err := executor.RunGit("status")
if err != nil {
panic(err)
}
fmt.Printf(result.Stdout.String())
}
Usage: with environment variables
import (
"fmt"
"os"
"strings"
"github.com/thombashi/go-gitexec"
)
func main() {
executor, err := gitexec.New(&gitexec.Params{
Env: []string{
"GIT_AUTHOR_NAME=John Doe",
"[email protected]",
},
})
if err != nil {
panic(err)
}
result, err := executor.RunGit("var", "GIT_AUTHOR_IDENT")
if err != nil {
panic(err)
}
fmt.Printf(result.Stdout.String())
}
# Functions
New creates a new GitExecutor instance.
# Interfaces
GitExecutor is an interface to execute Git commands.