This page is for SDK, version Current (default).
For other versions, use one of these documentation indexes:
- Current (default): https://buildwithfern.com/learn/sdks/current/llms.txt
- Legacy: https://buildwithfern.com/learn/sdks/legacy/llms.txt
本页面介绍如何为你的 Go SDK 添加自定义逻辑和方法。
These steps cover adding a new custom file to the SDK. To preserve line-level edits to a generated file, use
Replay instead.
添加自定义逻辑
开始添加自定义代码:
3使用辅助函数
Now your users can consume the helper function by importing it from the SDK.
添加自定义 SDK 方法
Fern also allows you to add custom methods to the SDK itself (e.g.
client.my_method() ) by inheriting the Fern generated client and then
extending it.
1更新 generators.yml 配置
将你的 Fern 生成的客户端命名为 BaseClient 之类的名称,以反映该客户端将被扩展。
2导入并扩展生成的客户端
首先,导入 Fern 生成的基础客户端并对其进行扩展。然后,添加你想要的任何方法。
3更新 .fernignore
将 client/my_client.go 添加到 .fernignore。
4使用方法
你的用户不需要构造生成的客户端,而是构造扩展的客户端。
Now your users can consume the helper function by importing it from the SDK.