fastscan

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Import added in v0.7.1

type Import struct {
	// Path of the imported file.
	Path string
	// Indicate if public or weak keyword was used in import statement.
	IsPublic, IsWeak bool
}

Import represents an import in a Protobuf source file.

type Result

type Result struct {
	PackageName string
	Imports     []Import
}

Result is the result of scanning a Protobuf source file. It contains the information extracted from the file.

func Scan

func Scan(filename string, r io.Reader) (Result, error)

Scan scans the given reader, which should contain Protobuf source, and returns the set of imports declared in the file. The result also contains the value of any package declaration in the file. It returns an error if there is an I/O error reading from r or if syntax errors are recognized while scanning. In the event of such an error, it will still return a result that contains as much information as was found (either before the I/O error occurred, or all that could be parsed despite syntax errors). The results are not necessarily valid, in that the parsed package name might not be a legal package name in protobuf or the imports may not refer to valid paths. Full validation of the source should be done using a full parser.

type SyntaxError added in v0.7.1

type SyntaxError []reporter.ErrorWithPos

SyntaxError is returned from Scan when one or more syntax errors are observed. Scan does not fully parse the source, so there are many kinds of syntax errors that will not be recognized. A full parser should be used to reliably detect errors in the source. But if the scanner happens to see things that are clearly wrong while scanning for the package and imports, it will return them. The slice contains one error for each location where a syntax issue is found.

func (SyntaxError) Error added in v0.7.1

func (e SyntaxError) Error() string

Error implements the error interface, returning an error message with the details of the syntax error issues.

func (SyntaxError) Unwrap added in v0.7.1

func (e SyntaxError) Unwrap() []error

Unwrap returns an error for each location where a syntax error was identified.

Jump to

Keyboard shortcuts

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