Go to file
Stanisław Barzowski b44e63e102 Bump officially supported Go version to 1.11
Go 1.8 has been unsupported for more than a year.
2019-12-20 15:48:45 +01:00
ast Add fodder to AST nodes (#319) 2019-09-24 12:11:22 +01:00
astgen Add fodder to AST nodes (#319) 2019-09-24 12:11:22 +01:00
bazel Allow use of Bazel repository externally 2019-07-04 13:09:47 +02:00
c-bindings Use backed by go-jsonnet for python extension 2019-12-19 18:09:09 +01:00
c-bindings-tests Implemented jsonnet_import_callback c-binding (#330) 2019-10-14 20:49:24 +02:00
cmd Fix Bazel config 2019-09-09 13:31:08 +02:00
cpp-jsonnet@552d8ec6f6 Release v0.14.0 2019-09-16 16:15:48 +02:00
internal break up parseObjectRemainder 2019-11-06 19:46:26 +00:00
linter Add fodder to AST nodes (#319) 2019-09-24 12:11:22 +01:00
python Python package now is called _gojsonnet for avoiding package collision 2019-12-19 18:09:09 +01:00
testdata Disallow unary + on Object 2019-09-23 13:07:05 +02:00
toolutils feat(parser): export parser.Children (#327) 2019-10-06 22:38:37 +02:00
.gitignore Changed python package name to gojsonnet 2019-12-19 18:09:09 +01:00
.gitmodules Add C++-Jsonnet submodule for tests (#202) 2018-03-06 13:05:00 -05:00
.travis.yml Bump officially supported Go version to 1.11 2019-12-20 15:48:45 +01:00
BUILD.bazel Fix Bazel config 2019-09-09 13:31:08 +02:00
builtins.go Disallow unary + on Object 2019-09-23 13:07:05 +02:00
CONTRIBUTING Add CONTRIBUTING, add newline to end of other files 2016-02-19 17:36:19 -05:00
doc.go Remove go:generate causing errors 2017-09-29 12:36:04 -04:00
error_formatter.go Unexport a bunch of symbols 2019-09-09 16:11:00 +02:00
go.mod break up parseObjectRemainder 2019-11-06 19:46:26 +00:00
go.sum Update x/sys to a newer version that supports Risc-V architecture (#284) 2019-06-17 15:10:00 +01:00
imports.go Better importing (caching & public API) 2019-09-23 15:37:10 +02:00
interpreter_test.go First end-to-end test (addition of numbers) 2016-03-08 01:17:44 -05:00
interpreter.go Add fodder to AST nodes (#319) 2019-09-24 12:11:22 +01:00
jsonnet_test.go Eliminate the unnecessary ast.StdAst 2019-09-01 21:17:29 +02:00
key.json.enc Adds TravisCI releaes process 2018-06-22 14:14:14 -04:00
LICENSE Add CONTRIBUTING, add newline to end of other files 2016-02-19 17:36:19 -05:00
main_test.go Make parser package internal 2019-09-03 17:28:33 +02:00
mutually_recursive_defaults.input Optional eval (#92) 2017-10-10 00:06:14 -04:00
README.md Bump officially supported Go version to 1.11 2019-12-20 15:48:45 +01:00
release.sh Fix build during release 2018-07-18 20:25:08 -04:00
reset_stdast_go.sh Fix unparsing of enums, avoid static type error 2017-11-08 11:28:38 -05:00
runtime_error.go Unexport a bunch of symbols 2019-09-09 16:11:00 +02:00
setup.py Python package now is called _gojsonnet for avoiding package collision 2019-12-19 18:09:09 +01:00
std.thisFile.jsonnet Optional eval (#92) 2017-10-10 00:06:14 -04:00
tests.sh Added python tests CI 2019-12-19 18:09:09 +01:00
thunks.go Add fodder to AST nodes (#319) 2019-09-24 12:11:22 +01:00
travisBazel.sh Check Bazel in Travis 2019-09-11 01:01:01 +02:00
travisBuild.sh Don't assume Go is in a specific directory 2019-06-08 18:59:32 +01:00
value.go Unexport a bunch of symbols 2019-09-09 16:11:00 +02:00
vm.go Implemented python gojsonnet get_version 2019-12-19 18:09:09 +01:00
WORKSPACE Allow use of Bazel repository externally 2019-07-04 13:09:47 +02:00

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.

Installation instructions

go get github.com/google/go-jsonnet/cmd/jsonnet

Build instructions (go 1.11+)

git clone github.com/google/go-jsonnet
cd go-jsonnet
go build ./cmd/jsonnet

To build with Bazel instead:

git clone github.com/google/go-jsonnet
cd go-jsonnet
git submodule init
git submodule update
bazel build //cmd/jsonnet

The resulting jsonnet program will then be available at a platform-specific path, such as bazel-bin/cmd/jsonnet/darwin_amd64_stripped/jsonnet for macOS.

Bazel also accommodates cross-compiling the program. To build the jsonnet program for various popular platforms, run the following commands:

Target platform Build command
Current host bazel build //cmd/jsonnet
Linux bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //cmd/jsonnet
macOS bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 //cmd/jsonnet
Windows bazel build --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64 //cmd/jsonnet

For additional target platform names, see the per-Go release definitions here in the rules_go Bazel package.

Additionally if any files were moved around, see the section Keeping the Bazel files up to date.

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

Updating and modifying the standard library

Standard library source code is kept in cpp-jsonnet submodule, because it is shared with Jsonnet C++ implementation.

For performance reasons we perform preprocessing on the standard library, so for the changes to be visible, regeneration is necessary:

git submodule init
git submodule update
go run cmd/dumpstdlibast/dumpstdlibast.go cpp-jsonnet/stdlib/std.jsonnet > astgen/stdast.go

The above command creates the astgen/stdast.go file which puts the desugared standard library into the right data structures, which lets us avoid the parsing overhead during execution. Note that this step is not necessary to perform manually when building with Bazel; the Bazel target regenerates the astgen/stdast.go (writing it into Bazel's build sandbox directory tree) file when necessary.

Keeping the Bazel files up to date

Note that we maintain the Go-related Bazel targets with the Gazelle tool. The Go module (go.mod in the root directory) remains the primary source of truth. Gazelle analyzes both that file and the rest of the Go files in the repository to create and adjust appropriate Bazel targets for building Go packages and executable programs.

After changing any dependencies within the files covered by this Go module, it is helpful to run go mod tidy to ensure that the module declarations match the state of the Go source code. In order to synchronize the Bazel rules with material changes to the Go module, run the following command to invoke Gazelle's update-repos command:

bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=bazel/deps.bzl%jsonnet_go_dependencies

Similarly, after adding or removing Go source files, it may be necessary to synchronize the Bazel rules by running the following command:

bazel run //:gazelle