{"id":37215324,"url":"https://github.com/iansmith/gopherjs","last_synced_at":"2026-01-15T00:54:25.421Z","repository":{"id":57611847,"uuid":"29889780","full_name":"iansmith/gopherjs","owner":"iansmith","description":"A compiler from Go (golang.org) to JavaScript for running Go code in a browser","archived":false,"fork":true,"pushed_at":"2015-01-27T00:55:34.000Z","size":2335,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-20T13:28:55.925Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"gopherjs/gopherjs","license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iansmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-27T00:40:12.000Z","updated_at":"2015-01-27T00:40:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/iansmith/gopherjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iansmith/gopherjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansmith%2Fgopherjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansmith%2Fgopherjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansmith%2Fgopherjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansmith%2Fgopherjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iansmith","download_url":"https://codeload.github.com/iansmith/gopherjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iansmith%2Fgopherjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28440729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:34:46.850Z","status":"ssl_error","status_checked_at":"2026-01-15T00:34:46.551Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-15T00:54:24.797Z","updated_at":"2026-01-15T00:54:25.413Z","avatar_url":"https://github.com/iansmith.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"GopherJS - A compiler from Go to JavaScript\n---------------------------------------------\n\n[![Circle CI](https://circleci.com/gh/gopherjs/gopherjs.svg?style=svg)](https://circleci.com/gh/gopherjs/gopherjs)\n\nGopherJS compiles Go code ([golang.org](http://golang.org/)) to pure JavaScript code. Its main purpose is to give you the opportunity to write front-end code in Go which will still run in all browsers. Give GopherJS a try on the [GopherJS Playground](http://gopherjs.github.io/playground/).\n\n### What is supported?\nNearly everything, including Goroutines ([compatibility table](doc/packages.md)). Performance is quite good in most cases, see [HTML5 game engine benchmark](http://ajhager.github.io/enj/).\n\n### Installation and Usage\nGet or update GopherJS and dependencies with:\n```\ngo get -u github.com/gopherjs/gopherjs\n```\nNow you can use  `gopherjs build [files]` or `gopherjs install [package]` which behave similar to the `go` tool. For `main` packages, these commands create a `.js` file and `.js.map` source map in the current directory or in `$GOPATH/bin`. The generated JavaScript file can be used as usual in a website. Use `gopherjs help [command]` to get a list of possible command line flags, e.g. for minification and automatically watching for changes. If you want to run the generated code with Node.js, see [this page](doc/syscalls.md).\n\n*Note: GopherJS will try to write compiled object files of the core packages to your $GOROOT/pkg directory. If that fails, it will fall back to $GOPATH/pkg.*\n\n### Performance Tips\n\n- Use the `-m` command line flag to generate minified code.\n- Apply gzip compression (http://en.wikipedia.org/wiki/HTTP_compression).\n- Use `int` instead of `(u)int8/16/32/64`.\n- Use `float64` instead of `float32`.\n\n### Community\n- [Google Group](https://groups.google.com/d/forum/gopherjs)\n- [Bindings to JavaScript APIs and libraries](https://github.com/gopherjs/gopherjs/wiki/bindings)\n- [GopherJS on Twitter](https://twitter.com/GopherJS)\n\n### Getting started\n#### Interacting with the DOM\nThe package `github.com/gopherjs/gopherjs/js` (see [documentation](http://godoc.org/github.com/gopherjs/gopherjs/js)) provides functions for interacting with native JavaScript APIs. For example the line\n```js\ndocument.write(\"Hello world!\");\n```\nwould look like this in Go:\n```go\njs.Global.Get(\"document\").Call(\"write\", \"Hello world!\")\n```\nYou may also want use the [DOM bindings](http://dominik.honnef.co/go/js/dom), the [jQuery bindings](https://github.com/gopherjs/jquery) (see [TodoMVC Example](https://github.com/gopherjs/todomvc)) or the [AngularJS bindings](https://github.com/gopherjs/go-angularjs). Those are some of the [bindings to JavaScript APIs and libraries](https://github.com/gopherjs/gopherjs/wiki/bindings) by community members.\n\n#### Providing library functions for use in other JavaScript code\nSet a global variable to a map that contains the functions:\n```go\npackage main\n\nimport \"github.com/gopherjs/gopherjs/js\"\n\nfunc main() {\n  js.Global.Set(\"myLibrary\", map[string]interface{}{\n    \"someFunction\": someFunction,\n  })\n}\n\nfunc someFunction() {\n  [...]\n}\n```\nFor more details see [Jason Stone's blog post](http://legacytotheedge.blogspot.de/2014/03/gopherjs-go-to-javascript-transpiler.html) about GopherJS.\n\n### Architecture\n\n#### General\nGopherJS emulates a 32-bit environment. This means that `int`, `uint` and `uintptr` have a precision of 32 bits. However, the explicit 64-bit integer types `int64` and `uint64` are supported. The `GOARCH` value of GopherJS is \"js\". You may use it as a build constraint: `// +build js`.\n\n#### Goroutines\nJavaScript has no concept of concurrency (except web workers, but those are too strictly separated to be used for goroutines). Because of that, instructions in JavaScript are never blocking. A blocking call would effectively freeze the responsiveness of your web page, so calls with callback arguments are used instead.\n\nGopherJS does some heavy lifting to work around this restriction: Whenever an instruction is blocking (e.g. communicating with a channel that isn't ready), the whole stack will unwind (= all functions return) and the goroutine will be put to sleep. Then another goroutine which is ready to resume gets picked and its stack with all local variables will be restored. This is done by preserving each stack frame inside a closure.\n\nThe performance of the code generated by this approach is quite good, but not as good as the simple nonblocking version. That's why GopherJS tries to be conservative about it. It will scan your code for functions that use blocking instructions and mark them as blocking accordingly. Then it will recursively mark all functions as blocking which have a call to some other function which is already know to be blocking. This works well for calls to package functions and for method calls on non-interface types. For calls to interface methods and to `func` values, however, it is not exactly known at compile time which function will be executed at runtime. In those cases you need to mark the call with the comment `//gopherjs:blocking` (no space after the slashes). Else, the call will panic at runtime.\n\nAlso, callbacks from external JavaScript code into Go code can never be blocking, but you may use the `go` statement to launch a new goroutine that may have blocking behavior:\n\n```go\njs.Global.Get(\"myButton\").Call(\"addEventListener\", \"click\", func() {\n  go func() {\n    someBlockingFuncion()\n  }()\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiansmith%2Fgopherjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiansmith%2Fgopherjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiansmith%2Fgopherjs/lists"}