github.com/goplusjs/gopherjs@v1.2.6-0.20211206034512-f187917453b8/doc/syscalls.md (about)

     1  System Calls
     2  ------------
     3  
     4  System calls are the bridge between your application and your operating system. They are used whenever you access something outside of your application's memory, for example when you write to the console, when you read or write files or when you access the network. In Go, system calls are mostly used by the `os` package, hence the name. When using GopherJS you need to consider if system calls are available or not.
     5  
     6  ### Output redirection to console
     7  
     8  If system calls are not available in your environment (see below), then a special redirection of `os.Stdout` and `os.Stderr` is applied. It buffers a line until it is terminated by a line break and then prints it via JavaScript's `console.log` to your browser's JavaScript console or your system console. That way, `fmt.Println` etc. work as expected, even if system calls are not available.
     9  
    10  ### In Browser
    11  
    12  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.
    13  
    14  ### Node.js on Linux and macOS
    15  
    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 10.0.0 (or newer). If you want to use an older version you can opt to not install the module, but then system calls are not available.
    17  
    18  Compile and install the module with:
    19  
    20  ```
    21  cd $GOPATH/src/github.com/gopherjs/gopherjs/node-syscall/
    22  npm install --global node-gyp
    23  node-gyp rebuild
    24  mkdir -p ~/.node_libraries/
    25  cp build/Release/syscall.node ~/.node_libraries/syscall.node
    26  ```
    27  
    28  ### Node.js on Windows
    29  
    30  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.
    31  
    32  ### Caveats
    33  
    34  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.