Help us shape the future of Go! Take the 2026 Go Developer Survey

purge

package
v7.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package purge strips the bodies of a Go source file so that only its declarations remain to be parsed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PurgeFuncBodies

func PurgeFuncBodies(src []byte) []byte

PurgeFuncBodies returns a copy of src in which the contents of each outermost {...} region have been deleted, except for struct and interface type bodies and the bodies of length-elided array literals ([...]T), whose element count is part of the type. It includes function bodies, function-literal bodies, and the bodies of slice, map, and explicitly-sized array composite literals (whose contents don't affect the type of the enclosing declaration). This reduces the amount of work required to parse the top-level declarations.

PurgeFuncBodies keeps the line breaks of what it deletes, so every line keeps its number; only columns after a deletion on its line move. If the input is invalid, parsing the output of PurgeFuncBodies may result in a different tree due to its effects on parser error recovery.

Types

This section is empty.

Jump to

Keyboard shortcuts

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