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

feat(go): Add configurable packageLayout setting #5713

Merged
merged 2 commits into from
Jan 22, 2025
Merged

Conversation

amckinney
Copy link
Member

This adds support for a few new configuration options, all of which are shown below:

# generators.yml
- name: fern-api/fern-go-sdk
  version: 0.36.0
  config:
    packageLayout: flat
    clientName: Acme
    clientConstructorName: New

By default, the Go SDK generates each nested client into a separate package to maximize backwards compatibility as the API evolves over time. However, some users acknowledge the risk and would prefer to have everything exported from the top-level package.

With the packageLayout: flat setting, the generated SDK will all be deposited at the root of the module, and the client can be constructed like so:

package main

import (
  "context"
  "fmt"
  "log"

  acme "github.com/acme/acme-go"
)
func main() {
  client := acme.New()
  response, err := client.GetUser(
    context.Background(),
    &acme.GetUserRequest{
      ID: "85307b0b-094b-41b5-b61d-347ca15e5da2",
    },
  )
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(response)
}

@amckinney amckinney requested a review from dsinghvi as a code owner January 22, 2025 23:36
Copy link

@amckinney amckinney merged commit 48aef74 into main Jan 22, 2025
54 checks passed
@amckinney amckinney deleted the amckinney/go/layout branch January 22, 2025 23:52
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