New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

go2js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

go2js

Compile Go to JS in the browser (using GopherJS)

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Go2JS

Compile Go to JS in the browser (using GopherJS)

Based on GopherJS Playground

The motive for this project was to enable client-side compiling of Golang to JavaScript to run in the browser for LocalPen.

Usage

<!-- <script src="https://cdn.jsdelivr.net/npm/go2js/build/index.js"></script> -->
<script src="index.js"></script>
<script>
  const code = `
package main
import "syscall/js"
func main() {fmt.Println("Hello, from Go")
js.Global().Call("alert", "Hello, JavaScript")
println("Hello, JS console")}
`;
  window.go2js
    .format(code)
    .then((formatted) => {
      console.log(formatted);
      // return window.go2js.compile(formatted,
      // 'https://cdn.jsdelivr.net/npm/go2js/build');
      return window.go2js.compile(formatted);
    })
    .then(eval)
    .catch(console.warn);
</script>

Run npm start to start a server (http://127.0.0.1:8080) and watch for changes.

Contribution

Please do!

Feedback, ideas and pull requests are highly appreciated.

License

BSD 2-Clause "Simplified" License same as GopherJS lisence

Support the author

ko-fi

FAQs

Package last updated on 19 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts