Categorygithub.com/rogpeppe/go-jsonnet
modulepackage
0.10.0
Repository: https://github.com/rogpeppe/go-jsonnet.git
Documentation: pkg.go.dev

# README

go-jsonnet

GoDoc Widget Travis Widget Coverage Status Widget

This an implementation of Jsonnet in pure Go. It is feature complete but is not as heavily exercised as the Jsonnet C++ implementation. Please try it out and give feedback.

This code is known to work on Go 1.8 and above. We recommend always using the newest stable release of Go.

Build instructions

export GOPATH=$HOME/go-workspace
mkdir -pv $GOPATH
go get github.com/google/go-jsonnet
cd $GOPATH/src/github.com/google/go-jsonnet
cd jsonnet
go build
./jsonnet /dev/stdin <<< '{x: 1, y: self.x} + {x: 10}'
{
   "x": 10,
   "y": 10
}

Running tests

./tests.sh  # Also runs `go test ./...`

Implementation Notes

We are generating some helper classes on types by using http://clipperhouse.github.io/gen/. Do the following to regenerate these if necessary:

go get github.com/clipperhouse/gen
go get github.com/clipperhouse/set
export PATH=$PATH:$GOPATH/bin  # If you haven't already
go generate

Generated Stdlib

To regenerate the standard library, do:

./reset_stdast_go.sh && go run cmd/dumpstdlibast.go

# Packages

Package ast provides AST nodes and ancillary structures and algorithms.
No description provided by the author
Package dump can dump a Go data structure to Go source file, so that it can be statically embedded into other code.
No description provided by the author
Package linter analyses Jsonnet code for code "smells".
Package parser reads Jsonnet files and parses them into AST nodes.

# Functions

MakeImportCache creates and ImportCache using an importer.
MakeVM creates a new VM with default parameters.
SnippetToAST parses a snippet and returns the resulting AST.
Version returns the Jsonnet version number.

# Structs

FileImporter imports data from files.
ImportCache represents a cache of imported data.
ImportCacheValue represents a value in an imported-data cache.
ImportedData represents imported data and where it came from.
MemoryImporter "imports" data from an in-memory map.
NativeFunction represents a function implemented in Go.
Parameters represents required position and optional named parameters for a function definition.
PlusSuperUnboundField represents a `field+: ...` that hasn't been bound to an object.
RuntimeError is an error discovered during evaluation of the program.
TraceElement represents tracing information, including a location range and a surrounding context.
TraceFrame is tracing information about a single frame of the call stack.
VM is the core interpreter and is the touchpoint used to parse and execute Jsonnet.

# Interfaces

An ErrorFormatter formats errors with stacktraces and color.
An Importer imports data from a path.

# Type aliases

ColorFormatter represents a function that writes to the terminal using color.
Hidden represents wether to include hidden fields in a lookup.