diff --git a/Makefile b/Makefile index a88399a81..440e5631e 100644 --- a/Makefile +++ b/Makefile @@ -121,7 +121,6 @@ generate: install-gen-deps ## Generate dynamically generated code @find post-processor common helper template builder provisioner -type f | xargs grep -l '^// Code generated' | xargs rm go generate ./... go fmt common/bootcommand/boot_command.go - go fmt command/plugin.go generate-check: generate ## Check go code generation is on par @echo "==> Checking that auto-generated code is not changed..." diff --git a/scripts/generate-plugins.go b/scripts/generate-plugins.go index 784046f7e..9b79e3ee2 100644 --- a/scripts/generate-plugins.go +++ b/scripts/generate-plugins.go @@ -15,6 +15,8 @@ import ( "path/filepath" "sort" "strings" + + "golang.org/x/tools/imports" ) const target = "command/plugin.go" @@ -58,6 +60,8 @@ func main() { } defer file.Close() + output = string(goFmt(target, []byte(output))) + _, err = file.WriteString(output) if err != nil { log.Fatalf("Failed writing to %s: %s", target, err) @@ -66,6 +70,15 @@ func main() { log.Printf("Generated %s", target) } +func goFmt(filename string, b []byte) []byte { + fb, err := imports.Process(filename, b, nil) + if err != nil { + log.Printf("formatting err: %v", err) + return b + } + return fb +} + type plugin struct { Package string // This plugin's package name (iso) PluginName string // Name of plugin (vmware-iso)