Search⌘ K

Analyzing Multi-git 0.1

Explore the walk-through of the Multi-git Go program, learning how to analyze its structure, parse commands, read environment variables, and execute Git commands across multiple repositories. This lesson prepares you to identify improvements in command-line Go programs.

We'll cover the following...

Analyzing the code

Before considering how to make the code better, let’s go over the code piece by piece to understand what it does. There is just one file, main.go. The first part just declares the main package and the list of imports. All the packages come from the standard library, and there are no external dependencies here.

package main

import (
	"flag"
	"fmt"
	"log"
	"os"
	"strings"
	"os/exec"
)

There is also just one function, main(). That’s pretty simple. The first thing the main function does is parse the command-line arguments using the flag standard library. There are ...