gocomment

package
v0.42.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gocomment turns OpenAPI description text into Go comment lines.

Descriptions are CommonMark and often carry inline HTML. Go comments are plain text, so markup is translated to readable text: links keep their text and absolute target, line-break tags become paragraph breaks, and other tags and emphasis markers are removed. Paragraphs are wrapped to a fixed width so generated comments read like hand-written ones.

Index

Constants

View Source
const Width = 76

Width is the preferred maximum length of comment text on one line. Words longer than the width, such as URLs, are never split.

Variables

This section is empty.

Functions

func Lines

func Lines(text string) []string

Lines returns text as comment lines without comment markers. Paragraphs are wrapped to Width and separated by an empty string. It returns nil when text holds nothing printable.

func Write

func Write(b *strings.Builder, indent string, lines []string)

Write appends lines to b as Go line comments, each starting with indent. An empty line becomes a bare comment marker.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL