generated

package module
v0.0.0-...-e1de015 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: BSD-3-Clause Imports: 4 Imported by: 2

Documentation

Overview

Package generated provides a function that parses a source file and reports whether it contains a "// Code generated … DO NOT EDIT." line comment.

It implements the specification at https://go.dev/s/generatedcode.

The first priority is correctness (no false negatives, no false positives). It must return accurate results even if the input source code is formatted unconventionally.

The second priority is performance. The current version uses bufio.Reader and ReadBytes. Performance can be optimized further by using lower level I/O primitives and allocating less. That can be explored later.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(src io.Reader) (hasGeneratedComment bool, err error)

Parse parses a source file provided via src, and reports whether the file contains a "// Code generated ... DO NOT EDIT." line comment matching the specification at https://go.dev/s/generatedcode:

To convey to humans and machine tools that code is generated,
generated source should have a line that matches the following
regular expression (in Go syntax):

	^// Code generated .* DO NOT EDIT\.$

This line must appear before the first non-comment, non-blank
text in the file.

func ParseFile

func ParseFile(filename string) (hasGeneratedComment bool, err error)

ParseFile opens the file specified by filename and uses Parse to parse it. If the source couldn't be read, the error indicates the specific failure.

Types

This section is empty.

Jump to

Keyboard shortcuts

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