func Apply(pkgs map[string][]*descriptor.File) (*plugin.CodeGeneratorResponse, error) {
	res := &plugin.CodeGeneratorResponse{}
	for _, files := range pkgs {
		for idx, file := range files {
			buf := new(bytes.Buffer)
			dest := &plugin.CodeGeneratorResponse_File{}
			destName := strings.TrimSuffix(file.Name, filepath.Ext(file.Name)) + ".pb.mw.go"
			dest.Name = &destName
			templateKey := pkgKey
			if idx == 0 {
				templateKey = initKey
			}
			if err := initCodeTpl.ExecuteTemplate(buf, templateKey, file); err != nil {
				return nil, err
			}
			ct := buf.String()
			dest.Content = &ct
			res.File = append(res.File, dest)
		}
	}
	return res, nil
}
// Apply applies the given package descriptors and generates the appropriate
// code using go templates.
Apply applies the given package descriptors and generates the appropriate
code using go templates.
// Apply applies the given package descriptors and generates the appropriate // code using go templates .
func Apply(pkgs map[string][]*descriptor.File) (*plugin.CodeGeneratorResponse, error) {
	res := &plugin.CodeGeneratorResponse{}
	for _, files := range pkgs {
		for idx, file := range files {
			buf := new(bytes.Buffer)
			dest := &plugin.CodeGeneratorResponse_File{}
			destName := strings.TrimSuffix(file.Name, filepath.Ext(file.Name)) + ".pb.mw.go"
			dest.Name = &destName
			templateKey := pkgKey
			if idx == 0 {
				templateKey = initKey
			}
			if err := initCodeTpl.ExecuteTemplate(buf, templateKey, file); err != nil {
				return nil, err
			}
			ct := buf.String()
			dest.Content = &ct
			res.File = append(res.File, dest)
		}
	}
	return res, nil
}
func Apply ( pkgs map [ string ] [ ] * descriptor . File ) ( * plugin . CodeGeneratorResponse , error ) { res := & plugin . CodeGeneratorResponse { } for _ , files := range pkgs { for idx , file := range files { buf := new ( bytes . Buffer ) dest := & plugin . CodeGeneratorResponse_File { } destName := strings . TrimSuffix ( file . Name , filepath . Ext ( file . Name ) ) + " " dest . Name = & destName templateKey := pkgKey if idx == 0 { templateKey = initKey } if err := initCodeTpl . ExecuteTemplate ( buf , templateKey , file ) ; err != nil { return nil , err } ct := buf . String ( ) dest . Content = & ct res . File = append ( res . File , dest ) } } return res , nil }
Apply applies the given package descriptors and generates the appropriate
code using go templates.
Apply applies the given package descriptors and generates the appropriate code using go templates .