This repo contains multiple packages used to generate Azure SDK's for Go:
- The
autorest.gopackage generates client code using autorest. - The
typespec-gopackage generates client code from typespec. - The
codegen.gopackage contains code used common by bothautorest.goandtypespec-go
This guide outlines the getting started steps to contributing to these generators.
- Prerequisites
- Step 1: Clone the repo
- Step 2: Build the code
- Step 3: Regenerate tests and samples
- Step 4: Test your changes
- Step 6: Make a PR
To set up your local development environment, we recommend forking this repo then cloning.
git clone https://github.com/<your-github-username>/autorest.go.git
Once you have the code locally, you can build it.
First, install all dependencies.
pnpm install
Then, build the code.
To build a specific package, navigate to that directory and run the command from there.
pnpm build
After making changes, build the code again, then run a regeneration command to see how your change has affected client code generation.
From the autorest.go/packages/autorest.go directory, run the following command:
pnpm regenerate
To regenerate a specific test:
pnpm regenerate --filter=TestName
From the autorest.go/packages/typespec-go directory, run the following command:
pnpm tspcompile
To regenerate a specific test:
pnpm tspcompile --filter=TestName
Verify changes made result in the output you expect.
For typespec-go, you can run tests using spector.
pnpm spector --start
~ run tests~
pnpm spector --stop
To debug the code generator:
- Set a break point
- In the TypeScript debug terminal in VSCode, run one of the regeneration commands from step 3
There are a number of custom pnpm commands to help with development. See the .scripts folder for more. Add the -w switch when executing the script from a directory other than the repo root.
NOTE: by default, the script will run against the entire repo. To limit its scope, pass a directory argument. E.g. when working from the /packages/autorest.go directory, to execute modtidy for only go.mod files under /packages/autorest.go, execute pnpm -w modtidy $pwd
To run go build and go vet on every generated module:
pnpm -w buildvet
To run go mod tidy on every generated module:
pnpm -w modtidy
If you have made changes to the emitter options in typespec-go, you need to update the documentation in typespec-azure repo.
- Run
pnpm run regen-docsfrom thepackages/typespec-godirectory to generate the documentation. - Copy the generated documentation folder
packages/typespec-go/websiteto the root folder oftypespec-azurerepo. - Commit the changes in the
typespec-azurerepo and make a PR in the repo.
Once you're satisfied with your changes, it's time to make a PR in the repo.
Before you do, make sure to:
- Format your code using the Prettier configuration file in the root of the repo
- Don't forget to rebuild and regenerate everything before pushing your changes