GithubHelp home page GithubHelp logo

gomonkey's Introduction

gomonkey

A Go wrapper around SpiderMonkey.

Installing

To install gomonkey you need a recent (>= 1.8.5) https://developer.mozilla.org/en/SpiderMonkey/ and have the js-config program in your $PATH, then just:

> go get github.com/zond/gomonkey
# github.com/zond/gomonkey
ld: library not found for -lgomonkey
collect2: ld returned 1 exit status

The error at the end is expected.

For some reason cgo is unable to link properly against recent SpiderMonkeys, and to fix this I created a small C wrapper that you compile and link using your regular old C compiler.

To build the wrapper and then install the library properly:

> cd $GOPATH/src/github.com/zond/gomonkey
> make
cc -fPIC -shared -o libgomonkey.dylib -I/usr/local/Cellar/spidermonkey/1.8.5/include/js -I/usr/local/Cellar/nspr/4.8.8/include/nspr -L/usr/local/Cellar/spidermonkey/1.8.5/lib -lmozjs185  c/gomonkey.c
> cd -
> go get github.com/zond/gomonkey

The Makefile is really trivial and probably won't work on your system (patches are welcome), but if it works you should now have a functional installation!

Testing

go test

What else?

Currently there isn't much more to do, even if you could look at https://github.com/zond/gomonkey/blob/master/gomonkey_test.go and figure out how to use this for other things than testing itself ;)

Why?

The reason I started this was that I tried to use go-v8, but never got the last step (makeing the wrapper and re-getting the library) to work properly, and I really wanted the JavaScript library I used to be installable via go get ....

And since SpiderMonkey already exports a C API it was (to me) preferable to use it instead of v8 (which AFAIK only exports a C++ API).

gomonkey's People

Contributors

zond avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.