mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
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.
This commit is contained in:
parent
d260c5f5e1
commit
378d865e84
1 changed files with 10 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue