google / google/go-jsonnet

JS bindings (GopherJS)

Open
#295 13 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
1.8k
Forks
263
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm trying to create a wrapper for a node js support using the `go-jsonnet` version of jsonnet rather than the the C++ version. I'm trying to use `gopherjs` to transpile `go-jsonnet` which can be used for node.js applications. I'm hoping by doing this, it will prove faster than the C++ version using emscripten and 🤞will also support imports.

I have an example go app setup following some advice from this [article](https://medium.com/@kentquirk/how-to-use-gopherjs-to-turn-go-code-into-a-javascript-library-1e947703db7a)

```go
package main

//go:generate gopherjs build --minify

// This is an experiment to see if gopherjs can reasonably generate js code from go source
// so that we can have a single-source solution for keys and addresses.
// Use "go generate" to build this.

import (
"crypto/sha256"

"github.com/gopherjs/gopherjs/js"
)

func main() {
js.Module.Get("exports").Set("hashit", hashit)
}

func hashit(s string) []byte {
h := sha256.New()
h.Write([]byte(s))
return h.Sum(nil)
}
```
However I'm unsure what I need to reference from jsonnet after following these instructions:

```bash
git clone github.com/google/go-jsonnet
cd go-jsonnet
go build ./cmd/jsonnet
```
Is there any chance anyone can point me in the right direction?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.