Jsonnet: How to install jsonnetfmt by go

Created on 29 Jan 2020  路  9Comments  路  Source: google/jsonnet

For some test in CI, it only needs jsonnetfmt cmd, but it failed with go install"

# go install 'github.com/google/go-jsonnet/cmd/jsonnetfmt'
can't load package: package github.com/google/go-jsonnet/cmd/jsonnetfmt: module github.com/google/go-jsonnet@latest found (v0.14.0), but does not contain package github.com/google/go-jsonnet/cmd/jsonnetfmt

Download binary pkg is not very cool in CI test, WDYT @sbarzowski ?

Most helpful comment

Yes, you can now install the Go version of jsonnetfmt by running:

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

All 9 comments

The only supported version of jsonnetfmt is the C++ one at the moment (because it's implementation defined, we don't want to support two version at the same time). So using a binary release be my default recommendation in this case. You may ofc also compile the C++ version - there are very few dependencies and it should take only a few seconds (still using a binary release is probably easier and faster for CI).

If you feel adventurous you may try using a fairly complete WIP by @sparkprime: https://github.com/sparkprime/go-jsonnet/tree/formatter.

@sparkprime BTW what is left to do before we can merge the Go implementation of jsonnetfmt and declare it the primary one?

Happy to heard it, beside CI test, there is too much env that does not support high C++ version, like CentOS7.6.
@sbarzowski Could share the implement process in this issue and close until implement done?

Sorry for my absenteeism!

There are few test cases still failing with the Go formatter. It's actually probably already useful so maybe we should disable those tests and merge it.

Yesterday I rebased it and it seems to be in the same condition I left it in, which is good!

What remains is:

  • "Could not parse floating point number." Some of the reformatter tests handle floating point literals that are valid syntax but do not fit in the double precision implementation. C++ rejected these at runtime but Go rejects them at parse time. That means these files cannot be reformatted as they cannot be parsed. I suggest we change the Go behaviour to match the C++ behaviour.
  • https://github.com/google/go-jsonnet/issues/314 which affects the formatter not because the behavior is different between the two implementations but because Go rejects it in the parser and the other one doesn't.
  • Some other minor stuff I can sort out myself easily

@sparkprime That sounds great! Where could we track the progress for go formatter? I'd love to help if I can anyhow.

pull https://github.com/sparkprime/go-jsonnet/tree/formatter, I just updated it. I will push -f in future though.

you should find the binary next to the regular jsonnet one and it should be self explanatory

Ok now we're down to just google/go-jsonnet#314

@sbarzowski @sparkprime Since https://github.com/google/go-jsonnet/pull/388 is merged, could we say this is done?

Yes, you can now install the Go version of jsonnetfmt by running:

go get github.com/google/go-jsonnet/cmd/jsonnetfmt
Was this page helpful?
0 / 5 - 0 ratings

Related issues

josdotso picture josdotso  路  3Comments

lukasheinrich picture lukasheinrich  路  7Comments

benley picture benley  路  9Comments

nnmrts picture nnmrts  路  9Comments

davidzchen picture davidzchen  路  6Comments