code: func NewGenerator(pkg, target string) (*Generator, error) {
  	var err error
  	if pkg == "" || pkg[0] == '.' {
  		pkg, err = filepath.Abs(filepath.Clean(pkg))
  		if err != nil {
  			return nil, err
  		}
  		pkg = gogenutil.StripGopath(pkg)
  	}
  	p, err := importer.Default().Import(pkg)
  	if err != nil {
  		return nil, err
  	}
  	obj := p.Scope().Lookup(target)
  	if obj == nil {
  		return nil, fmt.Errorf("struct %s missing", target)
  	}
  	if _, ok := obj.Type().Underlying().(*types.Struct); !ok {
  		return nil, fmt.Errorf("%s should be an struct, was %s", target, obj.Type().Underlying())
  	}
  	return &Generator{
  		targetName: target,
  		pkg:        p,
  		target:     obj.Type().Underlying().(*types.Struct),
  	}, nil
  }
docs: // NewGenerator initializes a Generator