Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feature): Add Go snippet generation #3035

Merged
merged 8 commits into from
Feb 22, 2024
Merged

(feature): Add Go snippet generation #3035

merged 8 commits into from
Feb 22, 2024

Conversation

amckinney
Copy link
Member

This introduces Go snippet generation for any API definition that defines examples, such as the following:

import (
  context "context"
  time "time"
  acme "github.com/acme/acme-go"
  acmeclient "github.com/acme/acme-go/client"
  option "github.com/acme/acme-go/option"
)

client := acmeclient.NewClient(
  option.WithToken(
    "<YOUR_AUTH_TOKEN>",
  ),
)
response, err := client.User.Create(
  context.TODO(),
  &acme.CreateUserRequest{
    Username: "john",
    Language: acme.LanguageEnglish,
  },
)

Given that this was such a substantial feature, this PR also moved the Go generator's seed tests into the top-level seed directory so that all of the generated Go fixtures exist alongside the rest of the generators.

This also resolved a small bug that caused package documentation to not be generated into the correct doc.go file, which sometimes resulted in non-deterministic generation results (i.e. the last doc.go won).

@amckinney amckinney requested a review from dsinghvi as a code owner February 22, 2024 04:48
Copy link
Member

@dsinghvi dsinghvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for moving the seed snapshots to the root

@amckinney amckinney merged commit a0a9069 into main Feb 22, 2024
27 of 30 checks passed
@amckinney amckinney deleted the amckinney/snippets branch February 22, 2024 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants