Ejemplo n.º 1
0
// Imports returns all the packages that have to be imported for the
func (g Generator) Imports() map[string]string {
	imports := imports.New(g.Package())
	for _, m := range g.Methods() {
		s := m.signature()
		imports.AddImportsFrom(s.Params())
		imports.AddImportsFrom(s.Results())
	}
	return imports.Imports()
}
Ejemplo n.º 2
0
func (g Generator) Imports() map[string]string {
	imports := imports.New(g.Package())
	fields := g.Fields()
	for i := 0; i < len(fields); i++ {
		m := fields[i]
		imports.AddImportsFrom(m.v.Type())
		imports.AddImportsFrom(m.UnderlyingType())
		if sub := m.UnderlyingTarget(); sub != nil {
			fields = append(fields, sub.Fields()...)
		}
	}
	return imports.Imports()
}