func (p *Project) Build() error {
	// If we are already in a directory named after the project, don't create it again
	wd, err := os.Getwd()
	if err != nil {
		return errors.Wrapf(err, "unable to get working directory")
	}

	if path.Base(wd) != p.Name {
		// Create Project destination folder if it does not exist already
		if err := os.MkdirAll(p.Path, config.DirMode); err != nil {
			return err
		}

		if err := os.Chdir(p.Path); err != nil {
			return errors.Wrapf(err, "could not build Project in '%s'", p.Path)
		}
	}

	// Build the directory and file layout
	p.buildDirs()
	p.buildFiles()

	// Initialise git and go modules
	if err := goMod(); err != nil {
		return err
	}

	if err := gitInit(); err != nil {
		return err
	}

	return nil
}
// Build creates the Project structure and writes files
Build creates the Project structure and writes files
// Build creates the Project structure and writes files
func (p *Project) Build() error {
	wd, err := os.Getwd()
	if err != nil {
		return errors.Wrapf(err, "unable to get working directory")
	}
	if path.Base(wd) != p.Name {
		if err := os.MkdirAll(p.Path, config.DirMode); err != nil {
			return err
		}
		if err := os.Chdir(p.Path); err != nil {
			return errors.Wrapf(err, "could not build Project in '%s'", p.Path)
		}
	}
	p.buildDirs()
	p.buildFiles()
	if err := goMod(); err != nil {
		return err
	}
	if err := gitInit(); err != nil {
		return err
	}
	return nil
}
func ( p * Project ) Build ( ) error { wd , err := os . Getwd ( ) if err != nil { return errors . Wrapf ( err , " " ) } if path . Base ( wd ) != p . Name { if err := os . MkdirAll ( p . Path , config . DirMode ) ; err != nil { return err } if err := os . Chdir ( p . Path ) ; err != nil { return errors . Wrapf ( err , " " , p . Path ) } } p . buildDirs ( ) p . buildFiles ( ) if err := goMod ( ) ; err != nil { return err } if err := gitInit ( ) ; err != nil { return err } return nil }
Build creates the Project structure and writes files
Build creates the Project structure and writes files
// If we are already in a directory named after the project, don't create it again // Create Project destination folder if it does not exist already // Build the directory and file layout // Initialise git and go modules