packagemainimport("fmt""log"git"github.com/purpleclay/gitz")funcmain(){client,_:=git.NewClient()cfg,err:=client.Config()iferr!=nil{log.Fatal("failed to retrieve config for current repository")}fmt.Println(cfg["user.name"])}
A batch of settings can be retrieved using ConfigL (local), ConfigS (system), or ConfigG (global). A partial retrieval is not supported and will fail if any are missing. All values for a setting are retrieved and ordered by the latest.
packagemainimport("fmt""log"git"github.com/purpleclay/gitz")funcmain(){client,_:=git.NewClient()cfg,err:=client.ConfigL("user.name","user.email")iferr!=nil{log.Fatal("failed to retrieve local config settings")}fmt.Println(cfg["user.name"][0])fmt.Println(cfg["user.email"][0])}
You can update multiple settings in a batch using ConfigSetL (local), ConfigSetS (system), or ConfigSetG (global). Pre-validation of config paths improves the chance of a successful update, but a partial batch may occur upon failure.
packagemainimport("log"git"github.com/purpleclay/gitz")funcmain(){client,_:=git.NewClient()err:=client.ConfigSetL("custom.setting1","value","custom.setting2","value")iferr!=nil{log.Fatal("failed to set local config settings")}}