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

validate

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package validate exposes tree-sitter syntax validation for external consumers.

This is the public API for mache's AST validation. It supports Go, Python, JavaScript, TypeScript, SQL, HCL, YAML, and Rust via tree-sitter grammars.

Usage:

err := validate.File("path/to/file.go")
errors := validate.FileErrors("path/to/file.go")
err := validate.Content([]byte("package main"), "main.go")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Content

func Content(content []byte, filePath string) error

Content parses content with tree-sitter for the language inferred from filePath's extension. Returns nil if the AST is clean or the language is unknown (pass-through).

func File

func File(filePath string) error

File reads a file from disk and validates its AST.

func SupportedExtension

func SupportedExtension(filePath string) bool

SupportedExtension returns true if the file extension is recognized by the tree-sitter grammar set.

Types

type ValidationError

type ValidationError = writeback.ValidationError

ValidationError contains structured information about a syntax error.

func ContentErrors

func ContentErrors(content []byte, filePath string) []ValidationError

ContentErrors returns all AST error locations for diagnostic reporting. Returns nil if no errors or unknown language.

func FileErrors

func FileErrors(filePath string) []ValidationError

FileErrors reads a file from disk and returns all AST error locations.

Jump to

Keyboard shortcuts

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