{"_rev":"3-dc03360979e7c6a428f7f7ff87c36e95","time":{"created":"2023-09-15T18:06:32.781Z","2.9.0":"2023-09-15T17:56:49.088Z","modified":"2023-09-15T18:06:33.441Z","2.9.1":"2023-09-15T18:06:33.142Z"},"_id":"@atifsyedali/nx-go","name":"@atifsyedali/nx-go","dist-tags":{"latest":"2.9.1"},"versions":{"2.9.1":{"name":"@atifsyedali/nx-go","version":"2.9.1","main":"src/index.js","generators":"./generators.json","executors":"./executors.json","homepage":"https://github.com/nx-go/nx-go","bugs":{"url":"https://github.com/nx-go/nx-go/issues"},"dependencies":{"fs-extra":"^9.1.0"},"license":"MIT","nx-migrations":{"migrations":"./migrations.json"},"typings":"./src/index.d.ts","description":"<div align=\"center\">   <h1>nx-go</h1>   <p>Nx plugin to use <a href=\"https://go.dev\">Go</a> in a <a href=\"https://nx.dev\">Nx</a> workspace.</p>   <img src=\"https://github.com/nx-go.png\" title=\"nx-go\" alt=\"nx-go logo\">   <h2>Using nx-go in your company? Co","_id":"@atifsyedali/nx-go@2.9.1","_integrity":"sha512-uKEyJoRQUJhoYiegwvSlzVkgQGRFSSPFcqU2ECTBUwFzFMwgj0KJ65eAWBMs40oYY65crkiRm6wp7TMSdHtttg==","_resolved":"/private/var/folders/10/pv_2wt915kvdnd3yz4rbpmh00000gp/T/87b4793128272bdd95a30634910d4237/atifsyedali-nx-go-2.9.1.tgz","_from":"file:atifsyedali-nx-go-2.9.1.tgz","_nodeVersion":"18.14.1","_npmVersion":"9.3.1","dist":{"integrity":"sha512-uKEyJoRQUJhoYiegwvSlzVkgQGRFSSPFcqU2ECTBUwFzFMwgj0KJ65eAWBMs40oYY65crkiRm6wp7TMSdHtttg==","shasum":"6c37c8c76820a8b912dca546749904850a39eae4","tarball":"https://registry.npmjs.org/@atifsyedali/nx-go/-/nx-go-2.9.1.tgz","fileCount":95,"unpackedSize":60797,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAst2moTCemktejyaevgi4wUKurtv2a8LI+8Srgh4B3OAiAkaG8qIAXHfeorNGmx0lZL87XJ/fevDo4FmadkgJibdw=="}]},"_npmUser":{"name":"atifsyedali","email":"atifsyedali@gmail.com"},"directories":{},"maintainers":[{"name":"atifsyedali","email":"atifsyedali@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nx-go_2.9.1_1694801192936_0.6114529546713312"},"_hasShrinkwrap":false}},"maintainers":[{"name":"atifsyedali","email":"atifsyedali@gmail.com"}],"description":"<div align=\"center\">   <h1>nx-go</h1>   <p>Nx plugin to use <a href=\"https://go.dev\">Go</a> in a <a href=\"https://nx.dev\">Nx</a> workspace.</p>   <img src=\"https://github.com/nx-go.png\" title=\"nx-go\" alt=\"nx-go logo\">   <h2>Using nx-go in your company? Co","homepage":"https://github.com/nx-go/nx-go","bugs":{"url":"https://github.com/nx-go/nx-go/issues"},"license":"MIT","readme":"<div align=\"center\">\n  <h1>nx-go</h1>\n  <p>Nx plugin to use <a href=\"https://go.dev\">Go</a> in a <a href=\"https://nx.dev\">Nx</a> workspace.</p>\n  <img src=\"https://github.com/nx-go.png\" title=\"nx-go\" alt=\"nx-go logo\">\n  <h2>Using nx-go in your company? Consider <a href=\"https://github.com/sponsors/beeman\">sponsoring me</a> and get priority support in the issues.</h2>\n</div>\n\n## Getting started\n\nFirst, make sure you have a Nx Workspace.\n\nCreate a new one using the following command:\n\n```bash\npnpm dlx create-nx-workspace go-playground --preset=empty --cli=nx --nx-cloud true\n## Or using yarn\n# yarn create nx-workspace go-playground --preset=empty --cli=nx --nx-cloud true\n## Or using npm\n# npm exec create-nx-workspace go-playground --preset=empty --cli=nx --nx-cloud true\n```\n\n```bash\ncd go-playground\n```\n\nNext, install the nx-go plugin:\n\n```bash\npnpm add -D @nx-go/nx-go\n## Or using yarn\n# yarn add -D @nx-go/nx-go\n## Or using npm\n# npm install -D @nx-go/nx-go\n```\n\nCreate a new application:\n\n```bash\nnx g @nx-go/nx-go:app api\n```\n\n## Usage\n\nYou can now run the Nx workspace commands:\n\n### Building the application\n\nThis command builds the application using the `go build` command, and stores the output in the `dist/<app-name>/` directory.\n\n```bash\nnx build api\n```\n\n### Linting the application\n\nLint the application using the `go fmt` command.\n\n```bash\nnx lint api\n```\n\n### Serving the application\n\nServes the application using the `go run` command.\n\n```bash\nnx serve api\n```\n\n#### Watch mode\n\nTo run the application in watch mode you can use `gow`, after [installing](https://github.com/mitranim/gow#installation) it on your machine.\n\nOpen the file `apps/<app-name>/project.json` and in the `targets.serve.options` object and set the `cmd` parameter to `gow` and the `cwd` parameter to `.`, like so:\n\n```json5\n{\n  targets: {\n    serve: {\n      executor: '@nx-go/nx-go:serve',\n      options: {\n        cmd: 'gow', // This is the cmd that will be used\n        cwd: '.', // Set working dir to project root so it picks up changes in `libs/*`\n        main: 'apps/api/main.go',\n      },\n    },\n  },\n}\n```\n\n### Testing the application\n\nTest the application using the `go test` command.\n\n```bash\nnx test api\n```\n\n## Docker\n\nIn order to build Docker containers from the Go api inside the Nx Workspace, there are 2 base images provided:\n\n- [nxgo/base](https://hub.docker.com/r/nxgo/base)\n  - Node 14 on Alpine, with Go 1.13\n- [nxgo/cli](https://hub.docker.com/r/nxgo/cli)\n  - Node 14 on Alpine, with Go 1.13\n  - [@angular/cli](https://github.com/angular/angular-cli) v10\n  - [@nrwl/cli](https://github.com/nrwl/nx) v10\n  - [nxpm](https://github.com/nxpm/nxpm-cli) v1\n\n### Using the base images:\n\n```dockerfile\n# Use nxgo/cli as the base image to do the build\nFROM nxgo/cli as builder\n\n# Create app directory\nWORKDIR /workspace\n\n# Copy package.json and the lock file\nCOPY package.json yarn.lock /workspace/\n\n# Install app dependencies\nRUN yarn\n\n# Copy source files\nCOPY . .\n\n# Build apps\nRUN yarn build api\n\n# This is the stage where the final production image is built\nFROM golang:1.17-alpine as final\n\n# Copy over artifacts from builder image\nCOPY --from=builder /workspace/dist/apps/api /workspace/api\n\n# Set environment variables\nENV PORT=3000\nENV HOST=0.0.0.0\n\n# Expose default port\nEXPOSE 3000\n\n# Start server\nCMD [ \"/workspace/api\" ]\n```\n\n## MIT License\n\nCreated by [Bram Borggreve](https://github.com/beeman).\n","readmeFilename":"README.md"}