Skip to content

Bug: protoc-gen-go dev folder cannot be regenerated after error #216

@abjeni

Description

@abjeni

Whenever I modify the template files and create a compilation error in the generated zorums files in the dev folder, I encounter a problem when I try to fix it.
The dev make rule is used to regenerate the dev files, it depends on installgorums which depends on gen_files which contains template_static.go, which is created using protoc-gen-gorums. protoc-gen-gorums crashes and prevents the dev folder from being regenerated.
I have found the error is in gorums_bundle.go, because of os.Exit(1). This is intended behavior, but combined with the makefile dependencies it becomes a problem.

// loadPackage returns the parsed package.
func loadPackage(pkgPath string) *packages.Package {
	cfg := &packages.Config{
		Mode: packages.NeedName | packages.NeedFiles | packages.NeedSyntax | packages.NeedImports | packages.NeedTypes | packages.NeedTypesInfo,
	}
	pkgs, err := packages.Load(cfg, pkgPath)
	if err != nil {
		log.Fatalf("failed to load %s: %v", pkgPath, err)
	}
	if packages.PrintErrors(pkgs) > 0 {
		os.Exit(1)
	}
	// Since Load succeeded and pkgPath is a single package, the following is safe
	return pkgs[0]
}

In order to reproduce this bug you can modify or delete a file in the dev folder to contain a bug, and run make dev.

I get around this issue by commenting out the protoc-gen-go file in the makefile each time I introduce a compiler error in the dev folder.
I once forgot to uncomment it and it slipped into commit d09d76f.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions