Back to godoc.org
github.com/open-policy-agent/opa/format

package format

v0.20.5
Latest Go to latest
Published: 3 days ago | License: Apache-2.0 | Module: github.com/open-policy-agent/opa

Overview

Package format implements formatting of Rego source files.

Index

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. If AST nodes are missing locations an arbitrary location will be used.

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.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier