From 378d865e84883dbba3d3442eca282237f56a5b34 Mon Sep 17 00:00:00 2001 From: Jeremy Schlatter Date: Fri, 28 Sep 2018 13:29:06 -0700 Subject: [PATCH] accounts/abi/bind: pass Go code through gofmt again goimports used to do this formatting. To keep the generated code in gofmt style, we now need to format it here ourselves. --- accounts/abi/bind/bind.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/accounts/abi/bind/bind.go b/accounts/abi/bind/bind.go index 3e4a439513..4dca4b4ea3 100644 --- a/accounts/abi/bind/bind.go +++ b/accounts/abi/bind/bind.go @@ -23,6 +23,7 @@ package bind import ( "bytes" "fmt" + "go/format" "regexp" "strings" "text/template" @@ -144,7 +145,15 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La if err := tmpl.Execute(buffer, data); err != nil { return "", err } - + // For Go bindings pass the code through gofmt to clean it up + if lang == LangGo { + code, err := format.Source(buffer.Bytes()) + if err != nil { + return "", fmt.Errorf("%v\n%s", err, buffer) + } + return string(code), nil + } + // For all others just return as is for now return buffer.String(), nil }