package main import ( "google.golang.org/protobuf/compiler/protogen" ) func (g *Generator) microGenerate(component string, plugin *protogen.Plugin) error { for _, file := range plugin.Files { if !file.Generate { continue } if len(file.Services) == 0 { continue } gname := file.GeneratedFilenamePrefix + "_" + component + ".pb.go" gfile := plugin.NewGeneratedFile(gname, file.GoImportPath) gfile.P("// Code generated by protoc-gen-micro") gfile.P("// source: ", *file.Proto.Name) gfile.P("package ", file.GoPackageName) gfile.P() gfile.Import(contextPackage) gfile.Import(microApiPackage) gfile.Import(microClientPackage) // generate services for _, service := range file.Services { generateServiceEndpoints(gfile, service) generateServiceClientInterface(gfile, service) generateServiceClientStreamInterface(gfile, service) generateServiceServerInterface(gfile, service) generateServiceServerStreamInterface(gfile, service) } } return nil }