func (g *codegen) generateHelpers(files []*protogen.File) {
	if len(files) == 0 {
		return
	}

	// find all messages referenced by the files.
	msgsToGen := make(map[string]*protogen.Message)
	for _, f := range files {
		for _, msg := range f.Messages {
			collectMessages(msgsToGen, msg)
		}
	}

	if len(msgsToGen) == 0 {
		return
	}

	fileName := filepath.Join(filepath.Dir(files[0].Desc.Path()), "hashpb_helpers.pb.go")
	gf := g.NewGeneratedFile(fileName, files[0].GoImportPath)
	gf.P("// Code generated by protoc-gen-go-hashpb. Do not edit.")
	gf.P("// protoc-gen-go-hashpb ", Version)
	gf.P()
	gf.P("package ", files[0].GoPackageName)
	gf.P()

	// sort message names to make the generated file predictable (no spurious diffs)
	msgNames := make([]string, len(msgsToGen))
	i := 0
	for mn := range msgsToGen {
		msgNames[i] = mn
		i++
	}
	sort.Strings(msgNames)

	for _, mn := range msgNames {
		g.genHelperForMsg(gf, msgsToGen[mn])
		gf.P()
	}
}
// generateHelpers generates helper functions for calculating the hash for each message type.
// Because messages can be recursive, we need to do this to avoid getting into an infinite loop.
generateHelpers generates helper functions for calculating the hash for each message type.
Because messages can be recursive, we need to do this to avoid getting into an infinite loop.
// generateHelpers generates helper functions for calculating the hash for each message type . // Because messages can be recursive we need to do this to avoid getting into an infinite loop .
func (g *codegen) generateHelpers(files []*protogen.File) {
	if len(files) == 0 {
		return
	}
	msgsToGen := make(map[string]*protogen.Message)
	for _, f := range files {
		for _, msg := range f.Messages {
			collectMessages(msgsToGen, msg)
		}
	}
	if len(msgsToGen) == 0 {
		return
	}
	fileName := filepath.Join(filepath.Dir(files[0].Desc.Path()), "hashpb_helpers.pb.go")
	gf := g.NewGeneratedFile(fileName, files[0].GoImportPath)
	gf.P("// Code generated by protoc-gen-go-hashpb. Do not edit.")
	gf.P("// protoc-gen-go-hashpb ", Version)
	gf.P()
	gf.P("package ", files[0].GoPackageName)
	gf.P()
	msgNames := make([]string, len(msgsToGen))
	i := 0
	for mn := range msgsToGen {
		msgNames[i] = mn
		i++
	}
	sort.Strings(msgNames)
	for _, mn := range msgNames {
		g.genHelperForMsg(gf, msgsToGen[mn])
		gf.P()
	}
}
func ( g * codegen ) generateHelpers ( files [ ] * protogen . File ) { if len ( files ) == 0 { return } msgsToGen := make ( map [ string ] * protogen . Message ) for _ , f := range files { for _ , msg := range f . Messages { collectMessages ( msgsToGen , msg ) } } if len ( msgsToGen ) == 0 { return } fileName := filepath . Join ( filepath . Dir ( files [ 0 ] . Desc . Path ( ) ) , " " ) gf := g . NewGeneratedFile ( fileName , files [ 0 ] . GoImportPath ) gf . P ( " " ) gf . P ( " " , Version ) gf . P ( ) gf . P ( " " , files [ 0 ] . GoPackageName ) gf . P ( ) msgNames := make ( [ ] string , len ( msgsToGen ) ) i := 0 for mn := range msgsToGen { msgNames [ i ] = mn i ++ } sort . Strings ( msgNames ) for _ , mn := range msgNames { g . genHelperForMsg ( gf , msgsToGen [ mn ] ) gf . P ( ) } }
generateHelpers generates helper functions for calculating the hash for each message type.
generateHelpers generates helper functions for calculating the hash for each message type .
// find all messages referenced by the files. // sort message names to make the generated file predictable (no spurious diffs)