Skip to content

Commit 3d28a7a

Browse files
authored
Update golang guidelines (#7457)
1 parent 2e76b7f commit 3d28a7a

2 files changed

Lines changed: 15 additions & 43 deletions

File tree

docs/golang/implementation.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ sidebar: general_sidebar
88

99
## API Implementation
1010

11-
TODO
11+
This section describes guidelines for implementing Azure SDK client libraries. Please note that some of these guidelines are automatically enforced by code generation tools.
1212

1313
### The Service Client
1414

15-
TODO
15+
Service clients are the main starting points for developers calling Azure services with the Azure SDK. Each client library should have at least one client, so it’s easy to discover. The guidelines in this section describe patterns for the design of a service client.
1616

1717
#### Service Methods
1818

19-
TODO
20-
2119
##### Using azcore.Pipeline
2220

2321
Each supported language has an Azure Core library that contains common mechanisms for cross cutting concerns such as configuration and doing HTTP requests.
@@ -40,28 +38,16 @@ The HTTP pipeline consists of a HTTP transport that is wrapped by multiple polic
4038

4139
##### Using azcore.Policy
4240

43-
TODO
44-
4541
#### Service Method Parameters
4642

47-
TODO
48-
4943
##### Parameter validation
5044

51-
TODO
52-
5345
### Supporting Types
5446

55-
TODO
56-
5747
#### Model Types
5848

59-
TODO
60-
6149
##### Serialization
6250

63-
TODO
64-
6551
#### Constants as Enumerations
6652

6753
{% include requirement/MUST id="golang-enum-type" %} define the enumeration's type to match the type sent/received over-the-wire (string is the most common example).
@@ -91,8 +77,6 @@ func PossibleWidgetColorValues() []WidgetColor {
9177

9278
## SDK Feature Implementation
9379

94-
TODO
95-
9680
### Configuration
9781

9882
{% include requirement/MUST id="golang-config-global" %} use relevant global configuration settings either by default or when explicitly requested to by the user, for example by passing in a configuration object to a client constructor.
@@ -160,8 +144,4 @@ Client libraries must support robust logging mechanisms so that the consumer can
160144

161145
### Telemetry
162146

163-
TODO
164-
165147
### Testing
166-
167-
TODO

docs/golang/introduction.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ folder: golang
66
sidebar: general_sidebar
77
---
88

9-
{% include draft.html content="The Go Language guidelines are in DRAFT status" %}
10-
119
## Introduction
1210

1311
The Go guidelines are for the benefit of client library designers targeting service applications written in [Go](https://golang.org/).
@@ -113,11 +111,11 @@ func NewWidgetClientFromConnectionString(connectionString string, options *Widge
113111

114112
##### Service Client Configuration
115113

116-
TODO
117-
118114
##### Setting the Service Version
119115

120-
TODO
116+
{% include requirement/MUST id="golang-api-service-client-versioning-highest-api" %} call the highest supported service API version by default.
117+
118+
{% include requirement/MUST id="golang-api-service-client-versioning-select-api-version" %} allow the consumer to explicitly select a supported service API version when instantiating the service client.
121119

122120
##### Client Immutability
123121

@@ -409,36 +407,24 @@ process(w)
409407

410408
##### Conditional Request Methods
411409

412-
TODO
413-
414410
##### Hierarchical Clients
415411

416-
TODO
417-
418412
### Supporting Types
419413

420414
In addition to service client types, Azure SDK APIs provide and use other supporting types as well.
421415

422416
#### Model Types
423417

424-
TODO
425-
426418
##### Model Type Naming
427419

428-
TODO
429-
430420
#### Constants as Enumerations
431421

432422
{% include requirement/MUST id="golang-const" %} use a `const` for parameters, fields, and return types when values are known.
433423

434424
#### Azure Core Types
435425

436-
TODO
437-
438426
#### Primitive Types
439427

440-
TODO
441-
442428
### Error Handling
443429

444430
{% include requirement/MUST id="golang-errors" %} return an error if a method fails to perform its intended functionality. For methods that return multiple items, the error object is always the last item in the return signature.
@@ -491,8 +477,6 @@ When implementing authentication, don't open up the consumer to security holes l
491477

492478
### Package Naming
493479

494-
TODO (namespaces in other languages)
495-
496480
### Support for Mocking
497481

498482
One of the key things we want to support is to allow consumers of the package to easily write repeatable unit-tests for their applications without activating a service. This allows them to reliably and quickly test their code without worrying about the vagaries of the underlying service implementation (including, for example, network conditions or service outages). Mocking is also helpful to simulate failures, edge cases, and hard to reproduce situations (for example: does code work on February 29th).
@@ -597,7 +581,9 @@ Packages should strive to avoid taking dependencies on packages outside of the s
597581

598582
### Native Code
599583

600-
TODO
584+
Native dependencies introduce lots of complexities and should be avoided.
585+
586+
{% include requirement/SHOULDNOT id="golang-problems-native-dependencies" %} use native dependencies.
601587

602588
### Doc Comments
603589

@@ -617,7 +603,13 @@ As you write your code, *doc it so you never hear about it again.* The less ques
617603

618604
### README
619605

620-
TODO
606+
{% include requirement/MUST id="golang-docs-readme" %} have a README.md file in the package root folder.
607+
608+
An example of a good `README.md` file can be found [here](https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/security/keyvault/azkeys/README.md).
609+
610+
{% include requirement/MUST id="golang-docs-readme-consumer" %} optimize the `README.md` for the consumer of the client library.
611+
612+
The contributor guide (`CONTRIBUTING.md`) should be a separate file linked to from the main component `README.md`.
621613

622614
### Samples
623615

0 commit comments

Comments
 (0)