package format

import "github.com/open-policy-agent/opa/format"

Package format implements formatting of Rego source files.

Index

Functions

func Ast

func Ast(x interface{}) (formatted []byte, err error)

Ast formats a Rego AST element. If the passed value is not a valid AST element, Ast returns nil and an error. Ast relies on all AST elements having non-nil Location values. If an AST element with a nil Location value is encountered, a default location will be set on the AST node.

func MustAst

func MustAst(x interface{}) []byte

MustAst is a helper function to format a Rego AST element. If any errors occurs this function will panic. This is mostly used for test

func Source

func Source(filename string, src []byte) ([]byte, error)

Source formats a Rego source file. The bytes provided must describe a complete Rego module. If they don't, Source will return an error resulting from the attempt to parse the bytes.

Source Files

format.go

Version
v0.19.2
Published
Apr 27, 2020
Platform
js/wasm
Imports
6 packages
Last checked
24 seconds ago

Tools for package owners.