utils

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultVersionedImportAlias

func DefaultVersionedImportAlias(importPath string) string

DefaultVersionedImportAlias 返回版本目录常用的生成包别名,例如 common/v1 -> commonv1。

func FormatGeneratedContent

func FormatGeneratedContent(filename string, content []byte) ([]byte, error)

FormatGeneratedContent 使用 gofmt 规则整理生成代码。

func FormatToolActionComment

func FormatToolActionComment(name, comment, action, toolKind string) string

FormatToolActionComment 生成 Tool 构造或注册方法注释。

func IsUnaryMethod

func IsUnaryMethod(method *protogen.Method) bool

IsUnaryMethod 判断当前 RPC 是否为普通一元调用。

func IsVersionSegment

func IsVersionSegment(source string) bool

IsVersionSegment 判断路径段是否为 v1/v2 这类 proto 版本目录。

func IsVersionedImportPath

func IsVersionedImportPath(importPath string) bool

IsVersionedImportPath 判断 import path 最后一段是否为 v1/v2 这类版本目录。

func NormalizeCommentText

func NormalizeCommentText(comments protogen.Comments) string

NormalizeCommentText 提取 proto 注释文本,并清理多余的注释标记与空白。

func ProtocVersion

func ProtocVersion(gen *protogen.Plugin) string

ProtocVersion 返回当前 protoc 编译器版本信息。

func StripRedundantImportAliases

func StripRedundantImportAliases(content []byte) ([]byte, error)

StripRedundantImportAliases 去掉冗余 import 别名,并修正版本目录包别名。

func ToolDescription

func ToolDescription(service *protogen.Service, method *protogen.Method) string

ToolDescription 生成 Tool 描述,优先使用 RPC 注释,其次使用 service 注释和方法名兜底。

func Unexport

func Unexport(source string) string

Unexport 将首字母转换为小写。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL