Only put exported methods in interfaces

このコミットが含まれているのは:
Cory Slep 2018-12-31 00:45:25 +01:00
コミット b79b381a62
2個のファイルの変更8行の追加2行の削除

ファイルの表示

@ -2,6 +2,7 @@ package codegen
import (
"github.com/dave/jennifer/jen"
"unicode"
)
// join appends a bunch of Go Code together, each on their own line.
@ -83,7 +84,9 @@ func (s *Struct) Constructors(name string) *Function {
func (s *Struct) ToInterface(pkg, name, comment string) *Interface {
fns := make([]FunctionSignature, 0, len(s.methods))
for _, m := range s.methods {
fns = append(fns, m.ToFunctionSignature())
if unicode.IsUpper([]rune(m.Name())[0]) {
fns = append(fns, m.ToFunctionSignature())
}
}
return NewInterface(pkg, name, fns, comment)
}

ファイルの表示

@ -2,6 +2,7 @@ package codegen
import (
"github.com/dave/jennifer/jen"
"unicode"
)
// Typedef defines a non-struct-based type, its functions, and its methods for
@ -71,7 +72,9 @@ func (t *Typedef) Constructors(name string) *Function {
func (t *Typedef) ToInterface(pkg, name, comment string) *Interface {
fns := make([]FunctionSignature, 0, len(t.methods))
for _, m := range t.methods {
fns = append(fns, m.ToFunctionSignature())
if unicode.IsUpper([]rune(m.Name())[0]) {
fns = append(fns, m.ToFunctionSignature())
}
}
return NewInterface(pkg, name, fns, comment)
}