in format.go [208:231]
func (un *formatter) Comment(id int64) string {
if !un.options.pretty {
return ""
}
start := un.info.GetStartLocation(id)
text, ok := un.src.Snippet(start.Line())
if !ok {
return ""
}
stop := un.info.GetStopLocation(id)
if stop.Column() <= len(text) {
text = text[stop.Column():]
}
idx := strings.LastIndex(text, "//")
if idx < 0 {
return ""
}
loc := location{start.Line(), stop.Column() + idx}
if _, ok := un.comments[loc]; ok {
return ""
}
un.comments[loc] = id
return " // " + strings.TrimSpace(strings.TrimPrefix(text[idx:], "//"))
}