https://github.com/liamzebedee/electron-go-picnic
Tools for using Go programs inside Electron apps
https://github.com/liamzebedee/electron-go-picnic
crossplatform electron golang nodejs
Last synced: 2 months ago
JSON representation
Tools for using Go programs inside Electron apps
- Host: GitHub
- URL: https://github.com/liamzebedee/electron-go-picnic
- Owner: liamzebedee
- Created: 2018-05-28T17:50:09.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-28T18:14:53.000Z (about 8 years ago)
- Last Synced: 2025-08-09T05:26:09.864Z (11 months ago)
- Topics: crossplatform, electron, golang, nodejs
- Language: JavaScript
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
electron-go-picnic
==================
Package that contains tools for using Go programs with Electron.
Originally extracted from my [Who's Hacking product](https://liamz.co/blog/building-spotifys-whos-listening-for-hackers/), which used my program [gitmonitor](https://github.com/liamzebedee/gitmonitor) to monitor live git repo changes across the system.
## Functions
- `getAppPath`, which gets the app path in development and production (when the app is unpacked from the archive).
- `getExecutableName` which finds the correct executable for OS and CPU arch.
- `getGOARCH` and `getGOOS`, wphich are used above.
## Install
`yarn add electron-go-picnic`
## Usage
1. Cross-compile your Go programs for all platforms at once (Windows/Linux/macOS) using `go-crosscompile.sh`.
2. Copy them to a directory in your Electron app. I advise `vendor/`.
3. Make sure your executable is unpacked in production so it can be run. E.g. with electron-builder, modify `package.json` in the "build" section and add:
```json
"asarUnpack": [
"vendor/"
]
```
4. Then in your Electron code:
```javascript
const spawn = require('child_process').spawn;
import { getAppPath, getExecutableName } from 'electron-go-picnic';
let cmd = path.join(getAppPath(), `/vendor/', getExecutableName('gitmon'));
spawn(cmd)
```