MCPcopy
hub / github.com/golang/protobuf / makeComments

Method makeComments

protoc-gen-go/generator/generator.go:1239–1251  ·  view source on GitHub ↗

makeComments generates the comment string for the field, no "\n" at the end

(path string)

Source from the content-addressed store, hash-verified

1237
1238// makeComments generates the comment string for the field, no "\n" at the end
1239func (g *Generator) makeComments(path string) (string, bool) {
1240 loc, ok := g.file.comments[path]
1241 if !ok {
1242 return "", false
1243 }
1244 w := new(bytes.Buffer)
1245 nl := ""
1246 for _, line := range strings.Split(strings.TrimSuffix(loc.GetLeadingComments(), "\n"), "\n") {
1247 fmt.Fprintf(w, "%s//%s", nl, line)
1248 nl = "\n"
1249 }
1250 return w.String(), true
1251}
1252
1253func (g *Generator) fileByName(filename string) *FileDescriptor {
1254 return g.allFilesByName[filename]

Callers 2

PrintCommentsMethod · 0.95
generateMessageMethod · 0.95

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected