ngo
Run Go commands from Node or CLI, Go env not required
Will download latest binaries locally if Go isn't already in PATH
BONUS
If you run a command and it fails with "cannot find package..." we'll try to install
said package(s). YAYS. :relieved:
local install
$ npm install --save ngo
cli install
$ npm install --global ngo
usage
cli usage
$ ngo version
$ ngo-update
$ ngo-binary golint test/fixtures/errors.go
programmatic usage
returns promise that resolves to execa
style object without the child_process
goodies
const goOpts = {}
const ngo = require('ngo')(goOpts)
const golint = ngo.bin('golint')
ngo('version').then(console.log).catch(console.error)
golint('main.go').then(console.log).catch(console.error)
api
const ngo = require('ngo')(options
)
- Purpose: initialize
ngo
- Arguments:
- options [
Object
- optional]
- useLocal [
Boolean
false
] - use locally downloaded Go binaries) - update [
Boolean
false
] - update local install to latest - installDeps [
Boolean
true
] - attempt to install missing packages - env [
Object
] - environment vars to set for the Go command - goRoot [
String
] - Go root path (ex. /usr/local/go
) - goPath [
String
] - Go workspace path (ex. ~/work
)
- Returns:
Function
(ngo
) which executes Go commands
ngo(commandArgs
, options
)
- Purpose: - execute
go
commands - Arguments:
- commandArgs [
Array
| String
- required] - argument(s) to call with go
command - options [
Object
- optional] - same options as
child_process.spawn
- additonal options available same as
execa
- Returns:
Promise
which resolves to execa
styled object
ngo.bin(binary
)
- Purpose: - execute commands on binaries in the
GOBIN
directory - Arguments:
- binary [
String
] - name of binary file to be executed in returned function
- Returns:
Function
(identical to ngo
, but runs specified binary instead of go
)
ngo.env
this is a copy of ngo's process.env
with the Go environment variables added to it
License
MIT © Andrew Carpenter