2.7.0 • Published 4 years ago
ngo v2.7.0
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 ngocli install
$ npm install --global ngousage
cli usage
$ ngo version
# go version go1.8.3 windows/amd64
# to update the `ngo` install of Go (won't update system version)
$ ngo-update
# go version go1.9.4 windows/amd64
# to set the `ngo` install of Go to a specific version (won't update system version)
$ ngo-version 1.12.0
# go version go1.12.0 windows/amd64
# to run a `go get` installed binary use this bs
$ ngo-binary golint test/fixtures/errors.go
# test\fixtures\errors.go:13:5: error var unexp should have name of the form errFooprogrammatic 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)
/* {
stdout: 'go version go1.8.3 windows/amd64',
stderr: '',
code: 0,
failed: false,
killed: false,
signal: null,
cmd: 'C:\\Go\\bin\\go version'
} */
golint('main.go').then(console.log).catch(console.error)api
const ngo = require('ngo')(options)
- Purpose: initialize
ngo - Arguments:
- options
Object- optional- useLocal
Booleanfalse- use locally downloaded Go binaries) - update
Booleanfalse- update local install to latest - installDeps
Booleantrue- 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)
- useLocal
- options
- Returns:
Function(ngo) which executes Go commands
ngo(commandArgs, options)
- Purpose: - execute
gocommands - Arguments:
- commandArgs
Array|String- required - argument(s) to call withgocommand - options
Object- optional - same options as
child_process.spawn - additonal options available same as
execa
- commandArgs
- Returns:
Promisewhich resolves toexecastyled object
ngo.bin(binary)
- Purpose: - execute commands on binaries in the
GOBINdirectory - Arguments:
- binary
String- name of binary file to be executed in returned function
- binary
- Returns:
Function(identical tongo, but runs specified binary instead ofgo)
ngo.env
this is a copy of ngo's process.env with the Go environment variables added to it
License
MIT © Andrew Carpenter
2.7.0
4 years ago
2.6.2
6 years ago
2.6.1
6 years ago
2.6.0
6 years ago
2.5.2
7 years ago
2.5.1
7 years ago
2.5.0
7 years ago
2.4.9
8 years ago
2.4.8
8 years ago
2.4.7
8 years ago
2.4.6
8 years ago
2.4.5
8 years ago
2.4.4
8 years ago
2.4.3
8 years ago
2.4.2
8 years ago
2.4.1
8 years ago
2.4.0
8 years ago
2.3.3
8 years ago
2.3.2
8 years ago
2.3.1
8 years ago
2.3.0
8 years ago
2.2.1
8 years ago
2.2.0
8 years ago
2.1.1
8 years ago
2.1.0
8 years ago
2.0.0
8 years ago
1.0.1
9 years ago
1.0.0
9 years ago