Documentation ¶
Overview ¶
Package goefmt implements an enhanced and reusable formatter for Go source code. The input is a gofmt formatted source code and the output is a simple representation of the code, consisting of lines and spans.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Format ¶
Format formats a tokenized Go source code returning a channel with each line (without the eol character) of the original source code. Each line consists of a sequence of source code spans for each token.
func Scan ¶
Scan scans the specified Go source file and returns a channel with Token.
The EOF token is not returned, and the last token does not contain the "\n" character.
func TokenClass ¶
TokenClass returns the HTML class for the specified code span.
Types ¶
type Token ¶
type Token struct { // Code is the token source code. // For keywords, identifiers and basic type literals, it is the token // literal. // For the auto inserted SEMICOLON operator, it is "\n". // For operators, it is the operator string representation. // For raw strings literals and general comments, carriage return // characters ('\r) are discarded. Code string // Whitespace is white space after the token. // It contains only spaces (U+0020), horizontal tabs (U+0009) and newlines // (U+000A). Whitespace string Value token.Token // contains filtered or unexported fields }
Token represents a Go token and associated source code, including white space.