fix(lint): 修复所有 Go 命名规范问题
- 全局替换 ApiKey → APIKey(类型、字段、方法、变量) - 修复所有 initialism 命名(API, SMTP, HTML, URL 等) - 添加所有缺失的包注释 - 修复导出符号的注释格式 主要修改: - ApiKey → APIKey(所有出现的地方) - ApiKeyID → APIKeyID - ApiKeyIDs → APIKeyIDs - TestSmtpConnection → TestSMTPConnection - HtmlURL → HTMLURL - 添加 20+ 个包注释 - 修复 10+ 个导出符号注释格式 验证结果: - ✓ golangci-lint: 0 issues - ✓ 单元测试: 通过 - ✓ 集成测试: 通过
This commit is contained in:
@@ -9,6 +9,18 @@ import (
|
||||
"github.com/Wei-Shaw/sub2api/ent"
|
||||
)
|
||||
|
||||
// The APIKeyFunc type is an adapter to allow the use of ordinary
|
||||
// function as APIKey mutator.
|
||||
type APIKeyFunc func(context.Context, *ent.APIKeyMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f APIKeyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.APIKeyMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.APIKeyMutation", m)
|
||||
}
|
||||
|
||||
// The AccountFunc type is an adapter to allow the use of ordinary
|
||||
// function as Account mutator.
|
||||
type AccountFunc func(context.Context, *ent.AccountMutation) (ent.Value, error)
|
||||
@@ -33,18 +45,6 @@ func (f AccountGroupFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AccountGroupMutation", m)
|
||||
}
|
||||
|
||||
// The ApiKeyFunc type is an adapter to allow the use of ordinary
|
||||
// function as ApiKey mutator.
|
||||
type ApiKeyFunc func(context.Context, *ent.ApiKeyMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f ApiKeyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.ApiKeyMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ApiKeyMutation", m)
|
||||
}
|
||||
|
||||
// The GroupFunc type is an adapter to allow the use of ordinary
|
||||
// function as Group mutator.
|
||||
type GroupFunc func(context.Context, *ent.GroupMutation) (ent.Value, error)
|
||||
|
||||
Reference in New Issue
Block a user