Adding a Helpers Package

In this lesson, we'll create another package that will contain some general utility function that is useful across the board and is not specific to multi-git. It is a good idea to separate this package and possibly share it so it can be imported by other projects.

The helpers package

In addition to the repo_manager package, let’s add a little helpers package. This package will contain some general functions that can be used later by various tests. Multi-git deals with files and directories managed by git. Two useful functions are CreateDir() and AddFiles().

The CreateDir() function creates a directory and optionally initializes git in that directory:

func CreateDir(baseDir string, name string, initGit bool) (err error) {
	dirName := path.Join(baseDir, name)
	err = os.MkdirAll(dirName, os.ModePerm)
	if err != nil {
		return
	}

	if !initGit {
		return
	}

	currDir, err := os.Getwd()
	if err != nil {
		return
	}
	defer
...