-
Notifications
You must be signed in to change notification settings - Fork 953
TypeSpec Go QuickStart
Go Azure SDK Design Guidelines is the overall design guideline of sdk. Make sure you are familiar with concepts such as "ServiceClient" and "Packages".
Make sure you are familiar with Git and Go Packages.
For service, it is usually your service name in REST API specifications. For instance, if the TypeSpec is under specification/storage, the service would normally be storage.
For package, please refer to Azure SDK Module Design in Go Guideline. For example, if the service name is storage, the package should be armstorage or azstorage.(Use arm for management-plane packages, and az for all other packages.)
☑️ Namespace is decided by SDK arch board.
After service and module, the output-dir would be <sdk-repository-dir>/sdk/<service>/<module>. This is where the SDK code should be generated when you call npx tsp compile.
☑️ It is recommended to configure TypeSpec package on REST API specifications. Please refer to these guidelines.
Particularly, here is a sample for tspconfig.yaml.
Please make sure service-dir, package-dir, module (for typespec-go) is correctly configured.
- "parameters.service-dir.default" would be
sdk/<service> - "options.@azure-tools/typespec-go.package-dir" would be
<package>
After configuration is completed, making a draft pull request on azure-rest-api-specs repository would automatically trigger SDK generation for all configured SDKs. The automation will create new pull request on azure-sdk-for-go repository. One can fork it for further development.
-
service-dir: Default assdk/<service>. If your service is a management-plane service, likespecification/azurefleet/AzureFleet.Management, the service dir needs to besdk/resourcemanager/computefleet. -
package-dir: Default as<package>. -
module: Default as "github.com/Azure/azure-sdk-for-go/{service-dir}/{package-dir}". -
generate-examples: Default astrue. Generates sample codes with the SDK.. -
generate-fakes: Default astrue. Generates test codes with the SDK.. -
fix-const-stuttering: Default astrue. Fix stuttering forconsttypes and values. -
head-as-boolean: Default astrue. HEAD requests will return a boolean value based on the HTTP status code. -
service-name: Used for ARM libraries. It is the name of the service. It will appear in the README.md and other places that refers to the service.