format

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package format implements formatting of Rego source files.

Index

Constants

This section is empty.

Variables

This section is empty.

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 Bytes

func Bytes(src []byte) ([]byte, error)

Bytes formats Rego source code. The bytes provided do not have to be an entire source file, but they must be parse-able. If the bytes are not parse-able, Bytes will return an error resulting from the attempt to parse them.

func MustAst added in v0.9.2

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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