// UpdateVersionFiles updates the version.go file with the version present in the VersionEnclosure enc. If version.go
// does not exist for a module, UpdateVersionFiles does not create one.
UpdateVersionFiles updates the version.go file with the version present in the VersionEnclosure enc. If version.go
does not exist for a module, UpdateVersionFiles does not create one.
// UpdateVersionFiles updates the version . go file with the version present in the VersionEnclosure enc . If version . go // does not exist for a module UpdateVersionFiles does not create one .
func (r *Repository) UpdateVersionFiles(enc VersionEnclosure) error {
	const versionGoFile = "version.go"
	const prefix = "const ModuleVersion = "
	const template = `const ModuleVersion = "%s"`
	modules, err := r.Modules()
	if err != nil {
		return fmt.Errorf("couldn't update version.go files: %v", err)
	}
	for _, m := range modules {
		v := enc.ModuleVersions[m].Version
		if v == "" {
			return fmt.Errorf("couldn't update version.go file for module %s: version is empty", m)
		}
		path := filepath.Join(r.RootPath, modToPath(m), versionGoFile)
		exists, err := util.FileExists(path, false)
		if err != nil {
			return fmt.Errorf("couldn't determine if %s exists for module %s: %v", versionGoFile, m, err)
		}
		if exists {
			err = util.ReplaceLine(path, prefix, fmt.Sprintf(template, v))
			if err != nil {
				return fmt.Errorf("couldn't update %s for module %s: %v", versionGoFile, m, err)
			}
		}
	}
	return nil
}
func ( r * Repository ) UpdateVersionFiles ( enc VersionEnclosure ) error { const versionGoFile = " " const prefix = " " const template = `const ModuleVersion = "%s"` modules , err := r . Modules ( ) if err != nil { return fmt . Errorf ( " " , err ) } for _ , m := range modules { v := enc . ModuleVersions [ m ] . Version if v == " " { return fmt . Errorf ( " " , m ) } path := filepath . Join ( r . RootPath , modToPath ( m ) , versionGoFile ) exists , err := util . FileExists ( path , false ) if err != nil { return fmt . Errorf ( " " , versionGoFile , m , err ) } if exists { err = util . ReplaceLine ( path , prefix , fmt . Sprintf ( template , v ) ) if err != nil { return fmt . Errorf ( " " , versionGoFile , m , err ) } } } return nil }
UpdateVersionFiles updates the version.go file with the version present in the VersionEnclosure enc.
UpdateVersionFiles updates the version . go file with the version present in the VersionEnclosure enc .