diff --git a/README.md b/README.md index b10362e83..8c5e09011 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ go get -u github.com/gopherjs/gopherjs Now you can use `gopherjs build [package]`, `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. +`gopherjs` uses your platform's default `GOOS` value when generating code. Supported `GOOS` values are: `linux`, `darwin`. If you're on a different platform (e.g., Windows or FreeBSD), you'll need to set the `GOOS` environment variable to a supported value. For example, `GOOS=linux gopherjs build [package]`. + *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.* #### gopherjs run, gopherjs test @@ -31,7 +33,7 @@ If you want to use `gopherjs run` or `gopherjs test` to run the generated code l npm install --global source-map-support ``` -For system calls (file system access, etc.), see [this page](https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md). +On supported `GOOS` platforms, it's possible to make system calls (file system access, etc.) available. See [doc/syscalls.md](https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md) for instructions on how to do so. #### gopherjs serve diff --git a/doc/syscalls.md b/doc/syscalls.md index 2ac55d314..abefd9edb 100644 --- a/doc/syscalls.md +++ b/doc/syscalls.md @@ -11,15 +11,12 @@ If system calls are not available in your environment (see below), then a specia The JavaScript environment of a web browser is completely isolated from your operating system to protect your machine. You don't want any web page to read or write files on your disk without your consent. That is why system calls are not and will never be available when running your code in a web browser. -### Node.js on Windows - -When running your code with Node.js on Windows, it is theoretically possible to use system calls. To do so, you would need a special Node.js module that provides direct access to system calls. However, since the interface is quite different from the one used on OS X and Linux, the system calls module included in GopherJS currently does not support Windows. Sorry. Get in contact if you feel like you want to change this situation. +### Node.js on Linux and macOS -### Node.js on OS X and Linux - -GopherJS has support for system calls on OS X and Linux. Before running your code with Node.js, you need to install the system calls module. The module is compatible with Node.js version 0.12 and above. If you want to use an older version you can opt to not install the module, but then system calls are not available. +GopherJS has support for system calls on Linux and macOS. Before running your code with Node.js, you need to install the system calls module. The module is compatible with Node.js version 0.12 and above. If you want to use an older version you can opt to not install the module, but then system calls are not available. Compile and install the module with: + ``` cd $GOPATH/src/github.com/gopherjs/gopherjs/node-syscall/ npm install --global node-gyp @@ -28,6 +25,10 @@ mkdir -p ~/.node_libraries/ cp build/Release/syscall.node ~/.node_libraries/syscall.node ``` +### Node.js on Windows + +When running your code with Node.js on Windows, it is theoretically possible to use system calls. To do so, you would need a special Node.js module that provides direct access to system calls. However, since the interface is quite different from the one used on Linux and macOS, the system calls module included in GopherJS currently does not support Windows. Sorry. Get in contact if you feel like you want to change this situation. + ### Caveats Note that even with syscalls enabled in Node.js, some programs may not behave as expected due to the fact that the current implementation blocks other goroutines during a syscall, which can lead to a deadlock in some situations. This is not considered a bug, as it is considered sufficient for most test cases (which is all Node.js should be used for). Get in contact if you feel like you want to change this situation.