func run()

in main.go [125:154]


func run(args []string, license, licensor string, exclude []string, ext string, copyright bool, dry bool, out io.Writer) error {
	header, ok := licensing.Headers[license]
	if !ok {
		return &Error{err: fmt.Errorf("unknown license: %s", license), code: errUnknownLicense}
	}

	var headerBytes []byte
	if copyright {
	        year, _, _ := time.Now().Date()
		headerBytes = append(headerBytes, []byte(fmt.Sprintf("// Copyright %d %s\n", year, licensor))...)
	}
	for i, line := range header {
		if strings.Contains(line, "%s") {
			header[i] = fmt.Sprintf(line, licensor)
		}
		headerBytes = append(headerBytes, []byte(header[i])...)
		headerBytes = append(headerBytes, []byte("\n")...)
	}

	var path = defaultPath
	if len(args) > 0 {
		path = args[0]
	}

	if _, err := os.Stat(path); err != nil {
		return &Error{err: err, code: exitFailedToStatTree}
	}

	return walk(path, ext, license, headerBytes, exclude, dry, out)
}