Skip to content

Commit 6d9f40b

Browse files
committed
Document supported GOOS values.
Add instructions for what people should do when building with GopherJS on unsupported platforms. Code generation works completely fine, but syscalls (e.g., for gopherjs run) will only work on supported platforms. Previously, this information was only in issues, people's heads, commit messages, etc. It should be documented in README to provide clarity. Rename "OS X" to "macOS", the current name of that operating system. Rearrange sections to place more relevant information first. Mention Linux before macOS consistently. Linux is placed first because it's open source and more freely available than the proprietary macOS, so it's easier to recommend it as an alternative. Resolves #770. Updates #776. Updates #688.
1 parent 97d8e76 commit 6d9f40b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ go get -u github.com/gopherjs/gopherjs
2121

2222
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.
2323

24+
`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]`.
25+
2426
*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.*
2527

2628
#### gopherjs run, gopherjs test
@@ -31,7 +33,7 @@ If you want to use `gopherjs run` or `gopherjs test` to run the generated code l
3133
npm install --global source-map-support
3234
```
3335

34-
For system calls (file system access, etc.), see [this page](https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md).
36+
System calls (file system access, etc.) will work only supported `GOOS` platforms (see above). See [doc/syscalls.md](https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md) for instructions.
3537

3638
#### gopherjs serve
3739

doc/syscalls.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ If system calls are not available in your environment (see below), then a specia
1111

1212
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.
1313

14-
### Node.js on Windows
15-
16-
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.
17-
18-
### Node.js on OS X and Linux
14+
### Node.js on Linux and macOS
1915

20-
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.
16+
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.
2117

2218
Compile and install the module with:
2319
```
@@ -28,6 +24,10 @@ mkdir -p ~/.node_libraries/
2824
cp build/Release/syscall.node ~/.node_libraries/syscall.node
2925
```
3026

27+
### Node.js on Windows
28+
29+
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.
30+
3131
### Caveats
3232

3333
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.

0 commit comments

Comments
 (0)