{"_id":"@dalongrong/mygo-npm","_rev":"3-b4c5fba9fe10c7d2d016f09f18789de3","time":{"created":"2022-11-09T05:29:50.360Z","1.0.0":"2022-11-09T05:13:36.829Z","modified":"2022-11-09T05:31:06.885Z","1.0.1":"2022-11-09T05:29:50.597Z","1.0.2":"2022-11-09T05:31:06.794Z"},"name":"@dalongrong/mygo-npm","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.1":{"name":"@dalongrong/mygo-npm","version":"1.0.1","description":"Distribute and install Go binaries via NPM","main":"index.js","bin":{"mygo-npm":"bin/index.js"},"scripts":{"p":"npm publish","test":"echo \"Error: no test specified\" && exit 1","prepublish":"node_modules/babel-cli/bin/babel.js src --out-dir bin --presets es2015"},"author":{"name":"Sanath Kumar Ramesh","email":"dayanandasaraswati@gmail.com"},"license":"Apache-2.0","dependencies":{"mkdirp":"^1.0.4","request":"^2.88.2","tar":"^6.1.12"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.com"},"repository":{"type":"git","url":"git+https://github.com/sanathkr/go-npm.git"},"homepage":"https://github.com/sanathkr/go-npm","devDependencies":{"babel-cli":"^6.24.1","babel-core":"^6.25.0","babel-preset-es2015":"^6.24.1"},"gitHead":"2a501331be51958533c2cc7f8be9533c90622928","bugs":{"url":"https://github.com/sanathkr/go-npm/issues"},"_id":"@dalongrong/mygo-npm@1.0.1","_nodeVersion":"14.18.2","_npmVersion":"6.14.15","_npmUser":{"name":"dalongrong","email":"1141591465@qq.com"},"dist":{"integrity":"sha512-Az2r7BFBK/0ltkc7QrgXKqFOsBEmuAADh+7RP1DVkJBs6MvohajEe/PpB58sYCAixLP8yQBQQZEZG5ndENjuHA==","shasum":"0507b04fee5ae5a0664f26132a63325333af2630","tarball":"https://registry.npmjs.org/@dalongrong/mygo-npm/-/mygo-npm-1.0.1.tgz","fileCount":5,"unpackedSize":24035,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC30lSRgk0KtbDh2DDeT5K5jJx23k18985F74qlULiSjAiA3oJw7t+t2lRpGdCKUm/O0om6TEgkvamscG4SEeKzo1w=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjazrOACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrEEg/9GgBuQMKQYjbCIxAbCMfSrIcPvQJadk4rncyitFERlxgepGTw\r\nhcvyxLbaKqZCRLoLxvRxXlYl4MPVXJNun17lou4dYKWIEirwxGA9tD+2U3yk\r\nFVzdFunBZ4K+pdGdUniEzRC/CMGqt5LA14KIOXcWcbtBaQzD66ZA7/EyMZgs\r\nqx30JoOdmwoICMN+0mVjYYTa2vpmFxos0AonO4tANpeJg63orty9kqSdrAOQ\r\nyf/8Gn4e6135XaqC1S58RhdQaEi52Li5WHfW9eMl1aHfwT3TBZsRyJdylWB7\r\nB+7NTO8JDKqAXXepEVK/ZNXId0W90VarAy2EjZj2etUTKrTPizdZuBXf4FUf\r\n8aOnb6hLAM/NQB3Umg/6G40Sq+lOXg2UFnT1VPQjRF9uW7JUyazKURRByhp8\r\nLlF3mvDxY+QyS7+YkpG7Ki5BswWds8NgI8Wtl1ORHPhvGZ/1NASMCUEzwnDC\r\nPvz07/FDAtcK1wGyxRfBMf4LAHp9OMyQQbtGBB6/QEJIqgJb7yzGAzJTIoAH\r\nxCpAXCxqRu7bOWWBq3sYX1zSbyqrrYOkCzxQjL/9TZaH7Qnsr8jBK7T3dGGH\r\nUMa0gJTSKYzzfXD33skEG30Diqj0C9sMTrLeE4u2uoPvVibFPJUhpxoUI+1w\r\npRsdpRRZXO6M+zP3AH1tHB/N9W58QNF6VHA=\r\n=P56J\r\n-----END PGP SIGNATURE-----\r\n"},"directories":{},"maintainers":[{"name":"dalongrong","email":"1141591465@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mygo-npm_1.0.1_1667971790410_0.5051073939945074"},"_hasShrinkwrap":false},"1.0.2":{"name":"@dalongrong/mygo-npm","version":"1.0.2","description":"Distribute and install Go binaries via NPM","main":"index.js","bin":{"mygo-npm":"bin/index.js"},"scripts":{"p":"npm publish","test":"echo \"Error: no test specified\" && exit 1","prepublish":"node_modules/babel-cli/bin/babel.js src --out-dir bin --presets es2015"},"author":{"name":"Sanath Kumar Ramesh","email":"dayanandasaraswati@gmail.com"},"license":"Apache-2.0","dependencies":{"mkdirp":"^1.0.4","request":"^2.88.2","tar":"^6.1.12"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.com"},"repository":{"type":"git","url":"git+https://github.com/sanathkr/go-npm.git"},"homepage":"https://github.com/sanathkr/go-npm","devDependencies":{"babel-cli":"^6.24.1","babel-core":"^6.25.0","babel-preset-es2015":"^6.24.1"},"gitHead":"2a501331be51958533c2cc7f8be9533c90622928","bugs":{"url":"https://github.com/sanathkr/go-npm/issues"},"_id":"@dalongrong/mygo-npm@1.0.2","_nodeVersion":"14.18.2","_npmVersion":"6.14.15","_npmUser":{"name":"dalongrong","email":"1141591465@qq.com"},"dist":{"integrity":"sha512-5NhW8ru4Aj0sccChrKHMEqHDn9PJd6vm2hKsZpVXZZjRwNxqdgELDP0LxqEG8XbsZ70RdsmPPHwZTp0cbyMZYA==","shasum":"b0d0d7f47d81e5bfdf1d1f85a74ddee78d4c6b04","tarball":"https://registry.npmjs.org/@dalongrong/mygo-npm/-/mygo-npm-1.0.2.tgz","fileCount":5,"unpackedSize":24035,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQChs2WSNYQ9Nmsk/AANt0w9VbDOMgKv+rw42iLtK0HpqAIgRDZB+eSFGbQxvYI2OV9PIkblWeyaNl/bBbopas1yg6E="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjazsaACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqC6Q/+N8jOuqeFUV0GsI44V5X+pkF8ftrHLQhHy3auuDvMYRKzSxnG\r\nLTSYbTNEi+MNWs0onfpYlo/cnigzbUi12P0RuPinJhAITSXmyg6X+OdeXp5B\r\n5SptDL8F3gJHoWNOzXY1+DhmZoYPo2UTkYhkaLP2G3bSdnD0dDz6vQYrODZd\r\n/m+8U4TWW9MrGVDuOnvqW7/PIpCxsVd81pflX0cny7nxNTGWTh/Nlkl328Mo\r\nNUX2CBqrPFoeZ07cUQ9TyEe++IzD53vOxknC40fTZbC4FfjnMKqonBZQRNYk\r\nv7Mv07Fn4p4Kr+iG8QGPNe8aN12mK5bpGV/k091I2Z1YEa8qWtC/EzIss6Ma\r\nVFW7W8cI2+jseKzXeFwzbXt04DVbNOvcSzz4FCZpPJnRTv6mJie65F1w/xl4\r\ncqIlJGqOVryz+nCO5gKbonHXFJq4ckhcNHGTKZiVoPJHMJMCTV1wm4jkOv7/\r\n+Gkm6QGB71cQgQzyi75G/AE6Oawx64IKGCK9JwNZPSA/iGEl5oEsH36KZCIY\r\nENXXAdH/WgQvJhCW1A6aoxE7RzwWKxGf+GSm1+c2FywwCfArSN6VAOvOZD+4\r\nxhp2aJNiS9ryhW3E+nV3unwzRNIkg0KLmjeVQHuwn150wCz7Na6dD1+uOEux\r\n01VDpcSs5FDjFHKjUY/OEhkxqf7pQme2UqQ=\r\n=spDV\r\n-----END PGP SIGNATURE-----\r\n"},"directories":{},"maintainers":[{"name":"dalongrong","email":"1141591465@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mygo-npm_1.0.2_1667971866551_0.032168501145634076"},"_hasShrinkwrap":false}},"maintainers":[{"name":"dalongrong","email":"1141591465@qq.com"}],"description":"Distribute and install Go binaries via NPM","homepage":"https://github.com/sanathkr/go-npm","repository":{"type":"git","url":"git+https://github.com/sanathkr/go-npm.git"},"author":{"name":"Sanath Kumar Ramesh","email":"dayanandasaraswati@gmail.com"},"bugs":{"url":"https://github.com/sanathkr/go-npm/issues"},"license":"Apache-2.0","readme":"## Go NPM\n### Distribute cross-platform Go binaries via NPM\n\nApplications written in Golang are portable - you can easily cross-compile binaries that work on Windows, Mac, and Linux. But how do you distribute the binaries to customers? When you publish new releases, how do they update the binary? \n\n**Use NPM to distribute cross-platform Go binaries**\n\n## Kidding me! Why NPM?\n* **Cross-platform**: NPM is the only popular package manager that works cross-platform. \n* **Lower barier to entry**: Most developers have NPM installed already. \n* **Pain free publishing**: It just takes one command to publish - `npm publish`\n* **Dead simple install & update story**: `npm install/update -g your-awesome-app`\n* **Adds $PATH**: NPM will automatically add your binary location to $PATH and generate .cmd file for Windows. Your app just works after installation! \n\n## Okay, tell me how?\n### 1. Publish your binaries\nSetup your Go application to compile and publish binaries to a file server. This could be Github Releases or Amazon S3 or even Dropbox. All you need is a link.\n\nI like to use [GoReleaser](https://github.com/goreleaser/goreleaser) to setup by release process. You create a simple YAML configuration file like this and run `goreleaser` CLI to publish binaries for various platform/architecture combination to Github:\n\n```\n# .goreleaser.yml\n# Build customization\nbuilds:\n  - binary: drum-roll\n    goos:\n      - windows\n      - darwin\n      - linux\n    goarch:\n      - amd64\n```\n\n`go-npm` will pull the appropriate binary for the platform & architecture where the package is being installed.\n\n### 2. Create a package.json file for your NPM app\nTo publish to NPM, you need to create a `package.json` file. You give your application a name, link to Readme, Github repository etc, and more importantly add `mygo-npm` as a dependency. You can create this file in an empty directory in your project or in a separate Git repository altogether. It is your choice.\n\n**Create package.json**\n\n`$ npm init`\n\nAnswer the questions to create an initial package.json file\n\n**Add go-npm dependency**\n\nFrom the directory containing package.json file, do\n\n`$ npm install @dalongrong/mygo-npm --save`\n\nThis will install go-npm under to your package.json file. It will also create a `node_modules` directory where the `@dalongrong/mygo-npm` package is downloaded. You don't need this directory since you are only going to publish the module and not consume it yourself. Let's go ahead and delete it.\n\n`$ rm -r node_modules`\n\n**Add postinstall and preuninstall scripts**\nHere is the magic: You ask to run `mygo-npm install` after it completes installing your package. This will pull down binaries from Github or Amazon S3 and install in NPM's `bin` directory. Binaries under bin directory are immediately available for use in your Terminal.\n\nEdit `package.json` file and add the following:\n```\n{\n    \"postinstall\": \"mygo-npm install\",\n    \"preuninstall\": \"mygo-npm uninstall\",\n}\n```\n\n`mygo-npm uninstall` simply deletes the binary from `bin` directory before NPM uninstalls your package.\n\n**Configure your binary path**\n\nYou need to tell `mygo-npm` where to download the binaries from, and where to install them. Edit `package.json` file and add the following configuration.\n\n```\n\"goBinary\": {\n      \"name\": \"command-name\",\n      \"path\": \"./bin\",\n      \"url\": \"https://github.com/user/my-go-package/releases/download/v{{version}}/myGoPackage_{{version}}_{{platform}}_{{arch}}.tar.gz\"\n```\n\n* *name*: Name of the command users will use to run your binary. \n* *path*: Temporary path where binaries will be downloaded to\n* *url*: HTTP Web server where binaries are hosted.\n\nFollowing variables are available to customize the URL:\n* `{{version}}`: Version number read from  `package.json` file. When you publish your package to NPM, it will use this version number. Ex: 0.0.1\n* `{{platform}}`: `$GOOS` value for the platform\n* `{{arch}}`: `$GOARCH` value for the architecture\n\nIf you use `goreleaser` to publish your modules, it will automatically set the right architecture & platform in your URL.\n\n**Publish to NPM**\n\nAll that's left now is publish to NPM. As I promised before, just one command\n\n`$ npm publish`\n\n### 3. Distribute to users\n\nTo install:\n\n`npm install -g your-app-name`\n\nTo Update:\n\n`npm update -g your-app-name`\n\n\n---\n\nWith ❤️ to the community by [Sanath Kumar Ramesh](http://twitter.com/sanathkr_)","readmeFilename":"README.md"}