chore: update goctl interface{} to any (#2819)

* chore: update goctl interface{} to any

* chore: update goctl interface{} to any
master
Kevin Wan 2 years ago committed by GitHub
parent ae87114282
commit eab904af64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -143,7 +143,7 @@ func file_hello_proto_rawDescGZIP() []byte {
} }
var file_hello_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_hello_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_hello_proto_goTypes = []interface{}{ var file_hello_proto_goTypes = []any{
(*HelloReq)(nil), // 0: hello.HelloReq (*HelloReq)(nil), // 0: hello.HelloReq
(*HelloResp)(nil), // 1: hello.HelloResp (*HelloResp)(nil), // 1: hello.HelloResp
} }
@ -163,7 +163,7 @@ func file_hello_proto_init() {
return return
} }
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_hello_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_hello_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*HelloReq); i { switch v := v.(*HelloReq); i {
case 0: case 0:
return &v.state return &v.state
@ -175,7 +175,7 @@ func file_hello_proto_init() {
return nil return nil
} }
} }
file_hello_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { file_hello_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*HelloResp); i { switch v := v.(*HelloResp); i {
case 0: case 0:
return &v.state return &v.state

@ -71,7 +71,7 @@ func RegisterGreetServer(s grpc.ServiceRegistrar, srv GreetServer) {
s.RegisterService(&Greet_ServiceDesc, srv) s.RegisterService(&Greet_ServiceDesc, srv)
} }
func _Greet_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _Greet_SayHello_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
in := new(HelloReq) in := new(HelloReq)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
@ -83,7 +83,7 @@ func _Greet_SayHello_Handler(srv interface{}, ctx context.Context, dec func(inte
Server: srv, Server: srv,
FullMethod: "/hello.Greet/SayHello", FullMethod: "/hello.Greet/SayHello",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req any) (any, error) {
return srv.(GreetServer).SayHello(ctx, req.(*HelloReq)) return srv.(GreetServer).SayHello(ctx, req.(*HelloReq))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)

@ -322,7 +322,7 @@ func file_hi_proto_rawDescGZIP() []byte {
} }
var file_hi_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_hi_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_hi_proto_goTypes = []interface{}{ var file_hi_proto_goTypes = []any{
(*HiReq)(nil), // 0: hi.HiReq (*HiReq)(nil), // 0: hi.HiReq
(*HelloReq)(nil), // 1: hi.HelloReq (*HelloReq)(nil), // 1: hi.HelloReq
(*HiResp)(nil), // 2: hi.HiResp (*HiResp)(nil), // 2: hi.HiResp
@ -350,7 +350,7 @@ func file_hi_proto_init() {
return return
} }
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_hi_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_hi_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*HiReq); i { switch v := v.(*HiReq); i {
case 0: case 0:
return &v.state return &v.state
@ -362,7 +362,7 @@ func file_hi_proto_init() {
return nil return nil
} }
} }
file_hi_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { file_hi_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*HelloReq); i { switch v := v.(*HelloReq); i {
case 0: case 0:
return &v.state return &v.state
@ -374,7 +374,7 @@ func file_hi_proto_init() {
return nil return nil
} }
} }
file_hi_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { file_hi_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*HiResp); i { switch v := v.(*HiResp); i {
case 0: case 0:
return &v.state return &v.state
@ -386,7 +386,7 @@ func file_hi_proto_init() {
return nil return nil
} }
} }
file_hi_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { file_hi_proto_msgTypes[3].Exporter = func(v any, i int) any {
switch v := v.(*HelloResp); i { switch v := v.(*HelloResp); i {
case 0: case 0:
return &v.state return &v.state
@ -398,7 +398,7 @@ func file_hi_proto_init() {
return nil return nil
} }
} }
file_hi_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { file_hi_proto_msgTypes[4].Exporter = func(v any, i int) any {
switch v := v.(*EventReq); i { switch v := v.(*EventReq); i {
case 0: case 0:
return &v.state return &v.state
@ -410,7 +410,7 @@ func file_hi_proto_init() {
return nil return nil
} }
} }
file_hi_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { file_hi_proto_msgTypes[5].Exporter = func(v any, i int) any {
switch v := v.(*EventResp); i { switch v := v.(*EventResp); i {
case 0: case 0:
return &v.state return &v.state

@ -85,7 +85,7 @@ func RegisterGreetServer(s grpc.ServiceRegistrar, srv GreetServer) {
s.RegisterService(&Greet_ServiceDesc, srv) s.RegisterService(&Greet_ServiceDesc, srv)
} }
func _Greet_SayHi_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _Greet_SayHi_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
in := new(HiReq) in := new(HiReq)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
@ -97,13 +97,13 @@ func _Greet_SayHi_Handler(srv interface{}, ctx context.Context, dec func(interfa
Server: srv, Server: srv,
FullMethod: "/hi.Greet/SayHi", FullMethod: "/hi.Greet/SayHi",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req any) (any, error) {
return srv.(GreetServer).SayHi(ctx, req.(*HiReq)) return srv.(GreetServer).SayHi(ctx, req.(*HiReq))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Greet_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _Greet_SayHello_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
in := new(HelloReq) in := new(HelloReq)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
@ -115,7 +115,7 @@ func _Greet_SayHello_Handler(srv interface{}, ctx context.Context, dec func(inte
Server: srv, Server: srv,
FullMethod: "/hi.Greet/SayHello", FullMethod: "/hi.Greet/SayHello",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req any) (any, error) {
return srv.(GreetServer).SayHello(ctx, req.(*HelloReq)) return srv.(GreetServer).SayHello(ctx, req.(*HelloReq))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
@ -193,7 +193,7 @@ func RegisterEventServer(s grpc.ServiceRegistrar, srv EventServer) {
s.RegisterService(&Event_ServiceDesc, srv) s.RegisterService(&Event_ServiceDesc, srv)
} }
func _Event_AskQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _Event_AskQuestion_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
in := new(EventReq) in := new(EventReq)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
@ -205,7 +205,7 @@ func _Event_AskQuestion_Handler(srv interface{}, ctx context.Context, dec func(i
Server: srv, Server: srv,
FullMethod: "/hi.Event/AskQuestion", FullMethod: "/hi.Event/AskQuestion",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req any) (any, error) {
return srv.(EventServer).AskQuestion(ctx, req.(*EventReq)) return srv.(EventServer).AskQuestion(ctx, req.(*EventReq))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)

@ -55,7 +55,7 @@ func generateModel(ctx *Context) error {
} }
output := filepath.Join(ctx.Output, fn+".go") output := filepath.Join(ctx.Output, fn+".go")
if err = util.With("model").Parse(text).GoFmt(true).SaveTo(map[string]interface{}{ if err = util.With("model").Parse(text).GoFmt(true).SaveTo(map[string]any{
"Type": stringx.From(t).Title(), "Type": stringx.From(t).Title(),
"lowerType": stringx.From(t).Untitle(), "lowerType": stringx.From(t).Untitle(),
"Cache": ctx.Cache, "Cache": ctx.Cache,
@ -80,7 +80,7 @@ func generateCustomModel(ctx *Context) error {
} }
output := filepath.Join(ctx.Output, fn+".go") output := filepath.Join(ctx.Output, fn+".go")
err = util.With("model").Parse(text).GoFmt(true).SaveTo(map[string]interface{}{ err = util.With("model").Parse(text).GoFmt(true).SaveTo(map[string]any{
"Type": stringx.From(t).Title(), "Type": stringx.From(t).Title(),
"lowerType": stringx.From(t).Untitle(), "lowerType": stringx.From(t).Untitle(),
"snakeType": stringx.From(t).ToSnake(), "snakeType": stringx.From(t).ToSnake(),
@ -108,7 +108,7 @@ func generateTypes(ctx *Context) error {
} }
output := filepath.Join(ctx.Output, fn+".go") output := filepath.Join(ctx.Output, fn+".go")
if err = util.With("model").Parse(text).GoFmt(true).SaveTo(map[string]interface{}{ if err = util.With("model").Parse(text).GoFmt(true).SaveTo(map[string]any{
"Type": stringx.From(t).Title(), "Type": stringx.From(t).Title(),
}, output, false); err != nil { }, output, false); err != nil {
return err return err

@ -122,7 +122,7 @@ goctl model 为go-zero下的工具模块中的组件之一目前支持识别m
func (m *defaultUserModel) FindOneByUser(user string) (*User, error) { func (m *defaultUserModel) FindOneByUser(user string) (*User, error) {
userKey := fmt.Sprintf("%s%v", cacheUserPrefix, user) userKey := fmt.Sprintf("%s%v", cacheUserPrefix, user)
var resp User var resp User
err := m.QueryRowIndex(&resp, userKey, m.formatPrimary, func(conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { err := m.QueryRowIndex(&resp, userKey, m.formatPrimary, func(conn sqlx.SqlConn, v any) (i any, e error) {
query := fmt.Sprintf("select %s from %s where user = ? limit 1", userRows, m.table) query := fmt.Sprintf("select %s from %s where user = ? limit 1", userRows, m.table)
if err := conn.QueryRow(&resp, query, user); err != nil { if err := conn.QueryRow(&resp, query, user); err != nil {
return nil, err return nil, err
@ -142,7 +142,7 @@ goctl model 为go-zero下的工具模块中的组件之一目前支持识别m
func (m *defaultUserModel) FindOneByName(name string) (*User, error) { func (m *defaultUserModel) FindOneByName(name string) (*User, error) {
userNameKey := fmt.Sprintf("%s%v", cacheUserNamePrefix, name) userNameKey := fmt.Sprintf("%s%v", cacheUserNamePrefix, name)
var resp User var resp User
err := m.QueryRowIndex(&resp, userNameKey, m.formatPrimary, func(conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { err := m.QueryRowIndex(&resp, userNameKey, m.formatPrimary, func(conn sqlx.SqlConn, v any) (i any, e error) {
query := fmt.Sprintf("select %s from %s where name = ? limit 1", userRows, m.table) query := fmt.Sprintf("select %s from %s where name = ? limit 1", userRows, m.table)
if err := conn.QueryRow(&resp, query, name); err != nil { if err := conn.QueryRow(&resp, query, name); err != nil {
return nil, err return nil, err
@ -162,7 +162,7 @@ goctl model 为go-zero下的工具模块中的组件之一目前支持识别m
func (m *defaultUserModel) FindOneByMobile(mobile string) (*User, error) { func (m *defaultUserModel) FindOneByMobile(mobile string) (*User, error) {
userMobileKey := fmt.Sprintf("%s%v", cacheUserMobilePrefix, mobile) userMobileKey := fmt.Sprintf("%s%v", cacheUserMobilePrefix, mobile)
var resp User var resp User
err := m.QueryRowIndex(&resp, userMobileKey, m.formatPrimary, func(conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { err := m.QueryRowIndex(&resp, userMobileKey, m.formatPrimary, func(conn sqlx.SqlConn, v any) (i any, e error) {
query := fmt.Sprintf("select %s from %s where mobile = ? limit 1", userRows, m.table) query := fmt.Sprintf("select %s from %s where mobile = ? limit 1", userRows, m.table)
if err := conn.QueryRow(&resp, query, mobile); err != nil { if err := conn.QueryRow(&resp, query, mobile); err != nil {
return nil, err return nil, err
@ -205,11 +205,11 @@ goctl model 为go-zero下的工具模块中的组件之一目前支持识别m
return err return err
} }
func (m *defaultUserModel) formatPrimary(primary interface{}) string { func (m *defaultUserModel) formatPrimary(primary any) string {
return fmt.Sprintf("%s%v", cacheUserIdPrefix, primary) return fmt.Sprintf("%s%v", cacheUserIdPrefix, primary)
} }
func (m *defaultUserModel) queryPrimary(conn sqlx.SqlConn, v, primary interface{}) error { func (m *defaultUserModel) queryPrimary(conn sqlx.SqlConn, v, primary any) error {
query := fmt.Sprintf("select %s from %s where id = ? limit 1", userRows, m.table) query := fmt.Sprintf("select %s from %s where id = ? limit 1", userRows, m.table)
return conn.QueryRow(v, query, primary) return conn.QueryRow(v, query, primary)
} }

@ -5,12 +5,12 @@ import (
) )
// Deprecated: Use github.com/zeromicro/go-zero/core/stores/builder.RawFieldNames instead. // Deprecated: Use github.com/zeromicro/go-zero/core/stores/builder.RawFieldNames instead.
func FieldNames(in interface{}) []string { func FieldNames(in any) []string {
return builder.RawFieldNames(in) return builder.RawFieldNames(in)
} }
// Deprecated: Use github.com/zeromicro/go-zero/core/stores/builder.RawFieldNames instead. // Deprecated: Use github.com/zeromicro/go-zero/core/stores/builder.RawFieldNames instead.
func RawFieldNames(in interface{}, postgresSql ...bool) []string { func RawFieldNames(in any, postgresSql ...bool) []string {
return builder.RawFieldNames(in, postgresSql...) return builder.RawFieldNames(in, postgresSql...)
} }

@ -33,7 +33,7 @@ func genDelete(table Table, withCache, postgreSql bool) (string, string, error)
output, err := util.With("delete"). output, err := util.With("delete").
Parse(text). Parse(text).
Execute(map[string]interface{}{ Execute(map[string]any{
"upperStartCamelObject": camel, "upperStartCamelObject": camel,
"withCache": withCache, "withCache": withCache,
"containsIndexCache": table.ContainsUniqueCacheKey, "containsIndexCache": table.ContainsUniqueCacheKey,
@ -57,7 +57,7 @@ func genDelete(table Table, withCache, postgreSql bool) (string, string, error)
deleteMethodOut, err := util.With("deleteMethod"). deleteMethodOut, err := util.With("deleteMethod").
Parse(text). Parse(text).
Execute(map[string]interface{}{ Execute(map[string]any{
"lowerStartCamelPrimaryKey": util.EscapeGolangKeyword(stringx.From(table.PrimaryKey.Name.ToCamel()).Untitle()), "lowerStartCamelPrimaryKey": util.EscapeGolangKeyword(stringx.From(table.PrimaryKey.Name.ToCamel()).Untitle()),
"dataType": table.PrimaryKey.DataType, "dataType": table.PrimaryKey.DataType,
"data": table, "data": table,

@ -37,7 +37,7 @@ func genField(table Table, field *parser.Field) (string, error) {
output, err := util.With("types"). output, err := util.With("types").
Parse(text). Parse(text).
Execute(map[string]interface{}{ Execute(map[string]any{
"name": util.SafeString(field.Name.ToCamel()), "name": util.SafeString(field.Name.ToCamel()),
"type": field.DataType, "type": field.DataType,
"tag": tag, "tag": tag,

@ -16,7 +16,7 @@ func genFindOne(table Table, withCache, postgreSql bool) (string, string, error)
output, err := util.With("findOne"). output, err := util.With("findOne").
Parse(text). Parse(text).
Execute(map[string]interface{}{ Execute(map[string]any{
"withCache": withCache, "withCache": withCache,
"upperStartCamelObject": camel, "upperStartCamelObject": camel,
"lowerStartCamelObject": stringx.From(camel).Untitle(), "lowerStartCamelObject": stringx.From(camel).Untitle(),
@ -39,7 +39,7 @@ func genFindOne(table Table, withCache, postgreSql bool) (string, string, error)
findOneMethod, err := util.With("findOneMethod"). findOneMethod, err := util.With("findOneMethod").
Parse(text). Parse(text).
Execute(map[string]interface{}{ Execute(map[string]any{
"upperStartCamelObject": camel, "upperStartCamelObject": camel,
"lowerStartCamelPrimaryKey": util.EscapeGolangKeyword(stringx.From(table.PrimaryKey.Name.ToCamel()).Untitle()), "lowerStartCamelPrimaryKey": util.EscapeGolangKeyword(stringx.From(table.PrimaryKey.Name.ToCamel()).Untitle()),
"dataType": table.PrimaryKey.DataType, "dataType": table.PrimaryKey.DataType,

@ -28,7 +28,7 @@ func genFindOneByField(table Table, withCache, postgreSql bool) (*findOneCode, e
for _, key := range table.UniqueCacheKey { for _, key := range table.UniqueCacheKey {
in, paramJoinString, originalFieldString := convertJoin(key, postgreSql) in, paramJoinString, originalFieldString := convertJoin(key, postgreSql)
output, err := t.Execute(map[string]interface{}{ output, err := t.Execute(map[string]any{
"upperStartCamelObject": camelTableName, "upperStartCamelObject": camelTableName,
"upperField": key.FieldNameJoin.Camel().With("").Source(), "upperField": key.FieldNameJoin.Camel().With("").Source(),
"in": in, "in": in,
@ -68,7 +68,7 @@ func genFindOneByField(table Table, withCache, postgreSql bool) (*findOneCode, e
if len(inJoin) > 0 { if len(inJoin) > 0 {
in = inJoin.With(", ").Source() in = inJoin.With(", ").Source()
} }
output, err := t.Execute(map[string]interface{}{ output, err := t.Execute(map[string]any{
"upperStartCamelObject": camelTableName, "upperStartCamelObject": camelTableName,
"upperField": key.FieldNameJoin.Camel().With("").Source(), "upperField": key.FieldNameJoin.Camel().With("").Source(),
"in": in, "in": in,
@ -88,7 +88,7 @@ func genFindOneByField(table Table, withCache, postgreSql bool) (*findOneCode, e
return nil, err return nil, err
} }
out, err := util.With("findOneByFieldExtraMethod").Parse(text).Execute(map[string]interface{}{ out, err := util.With("findOneByFieldExtraMethod").Parse(text).Execute(map[string]any{
"upperStartCamelObject": camelTableName, "upperStartCamelObject": camelTableName,
"primaryKeyLeft": table.PrimaryCacheKey.VarLeft, "primaryKeyLeft": table.PrimaryCacheKey.VarLeft,
"lowerStartCamelObject": stringx.From(camelTableName).Untitle(), "lowerStartCamelObject": stringx.From(camelTableName).Untitle(),

@ -354,7 +354,7 @@ func (g *defaultGenerator) genModelCustom(in parser.Table, withCache bool) (stri
t := util.With("model-custom"). t := util.With("model-custom").
Parse(text). Parse(text).
GoFmt(true) GoFmt(true)
output, err := t.Execute(map[string]interface{}{ output, err := t.Execute(map[string]any{
"pkg": g.pkg, "pkg": g.pkg,
"withCache": withCache, "withCache": withCache,
"upperStartCamelObject": in.Name.ToCamel(), "upperStartCamelObject": in.Name.ToCamel(),
@ -375,7 +375,7 @@ func (g *defaultGenerator) executeModel(table Table, code *code) (*bytes.Buffer,
t := util.With("model"). t := util.With("model").
Parse(text). Parse(text).
GoFmt(true) GoFmt(true)
output, err := t.Execute(map[string]interface{}{ output, err := t.Execute(map[string]any{
"pkg": g.pkg, "pkg": g.pkg,
"imports": code.importsCode, "imports": code.importsCode,
"vars": code.varsCode, "vars": code.varsCode,

@ -30,7 +30,7 @@ func genImports(table Table, withCache, timeImport bool) (string, error) {
return "", err return "", err
} }
buffer, err := util.With("import").Parse(text).Execute(map[string]interface{}{ buffer, err := util.With("import").Parse(text).Execute(map[string]any{
"time": timeImport, "time": timeImport,
"containsPQ": table.ContainsPQ, "containsPQ": table.ContainsPQ,
"data": table, "data": table,

@ -58,7 +58,7 @@ func genInsert(table Table, withCache, postgreSql bool) (string, string, error)
output, err := util.With("insert"). output, err := util.With("insert").
Parse(text). Parse(text).
Execute(map[string]interface{}{ Execute(map[string]any{
"withCache": withCache, "withCache": withCache,
"upperStartCamelObject": camel, "upperStartCamelObject": camel,
"lowerStartCamelObject": stringx.From(camel).Untitle(), "lowerStartCamelObject": stringx.From(camel).Untitle(),
@ -78,7 +78,7 @@ func genInsert(table Table, withCache, postgreSql bool) (string, string, error)
return "", "", err return "", "", err
} }
insertMethodOutput, err := util.With("insertMethod").Parse(text).Execute(map[string]interface{}{ insertMethodOutput, err := util.With("insertMethod").Parse(text).Execute(map[string]any{
"upperStartCamelObject": camel, "upperStartCamelObject": camel,
"data": table, "data": table,
}) })

@ -21,7 +21,7 @@ func genNew(table Table, withCache, postgreSql bool) (string, error) {
output, err := util.With("new"). output, err := util.With("new").
Parse(text). Parse(text).
Execute(map[string]interface{}{ Execute(map[string]any{
"table": t, "table": t,
"withCache": withCache, "withCache": withCache,
"upperStartCamelObject": table.Name.ToCamel(), "upperStartCamelObject": table.Name.ToCamel(),

@ -14,7 +14,7 @@ func genTableName(table Table) (string, error) {
output, err := util.With("tableName"). output, err := util.With("tableName").
Parse(text). Parse(text).
Execute(map[string]interface{}{ Execute(map[string]any{
"tableName": table.Name.Source(), "tableName": table.Name.Source(),
"upperStartCamelObject": table.Name.ToCamel(), "upperStartCamelObject": table.Name.ToCamel(),
}) })

@ -16,7 +16,7 @@ func genTag(table Table, in string) (string, error) {
return "", err return "", err
} }
output, err := util.With("tag").Parse(text).Execute(map[string]interface{}{ output, err := util.With("tag").Parse(text).Execute(map[string]any{
"field": in, "field": in,
"data": table, "data": table,
}) })

@ -21,7 +21,7 @@ func genTypes(table Table, methods string, withCache bool) (string, error) {
output, err := util.With("types"). output, err := util.With("types").
Parse(text). Parse(text).
Execute(map[string]interface{}{ Execute(map[string]any{
"withCache": withCache, "withCache": withCache,
"method": methods, "method": methods,
"upperStartCamelObject": table.Name.ToCamel(), "upperStartCamelObject": table.Name.ToCamel(),

@ -95,7 +95,7 @@ func genUpdate(table Table, withCache, postgreSql bool) (
} }
updateMethodOutput, err := util.With("updateMethod").Parse(text).Execute( updateMethodOutput, err := util.With("updateMethod").Parse(text).Execute(
map[string]interface{}{ map[string]any{
"upperStartCamelObject": camelTableName, "upperStartCamelObject": camelTableName,
"data": table, "data": table,
}, },

@ -26,7 +26,7 @@ func genVars(table Table, withCache, postgreSql bool) (string, error) {
} }
output, err := util.With("var").Parse(text). output, err := util.With("var").Parse(text).
GoFmt(true).Execute(map[string]interface{}{ GoFmt(true).Execute(map[string]any{
"lowerStartCamelObject": stringx.From(camel).Untitle(), "lowerStartCamelObject": stringx.From(camel).Untitle(),
"upperStartCamelObject": camel, "upperStartCamelObject": camel,
"cacheKeys": strings.Join(keys, "\n"), "cacheKeys": strings.Join(keys, "\n"),

@ -24,14 +24,14 @@ type (
// DbColumn defines column info of columns // DbColumn defines column info of columns
DbColumn struct { DbColumn struct {
Name string `db:"COLUMN_NAME"` Name string `db:"COLUMN_NAME"`
DataType string `db:"DATA_TYPE"` DataType string `db:"DATA_TYPE"`
ColumnType string `db:"COLUMN_TYPE"` ColumnType string `db:"COLUMN_TYPE"`
Extra string `db:"EXTRA"` Extra string `db:"EXTRA"`
Comment string `db:"COLUMN_COMMENT"` Comment string `db:"COLUMN_COMMENT"`
ColumnDefault interface{} `db:"COLUMN_DEFAULT"` ColumnDefault any `db:"COLUMN_DEFAULT"`
IsNullAble string `db:"IS_NULLABLE"` IsNullAble string `db:"IS_NULLABLE"`
OrdinalPosition int `db:"ORDINAL_POSITION"` OrdinalPosition int `db:"ORDINAL_POSITION"`
} }
// DbIndex defines index of columns in information_schema.statistic // DbIndex defines index of columns in information_schema.statistic

@ -112,7 +112,7 @@ func (m *PostgreSqlModel) getColumns(schema, table string, in []*PostgreColumn)
var list []*Column var list []*Column
for _, e := range in { for _, e := range in {
var dft interface{} var dft any
if len(e.ColumnDefault.String) > 0 { if len(e.ColumnDefault.String) > 0 {
dft = e.ColumnDefault dft = e.ColumnDefault
} }

@ -1,8 +1,8 @@
func (m *default{{.upperStartCamelObject}}Model) formatPrimary(primary interface{}) string { func (m *default{{.upperStartCamelObject}}Model) formatPrimary(primary any) string {
return fmt.Sprintf("%s%v", {{.primaryKeyLeft}}, primary) return fmt.Sprintf("%s%v", {{.primaryKeyLeft}}, primary)
} }
func (m *default{{.upperStartCamelObject}}Model) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { func (m *default{{.upperStartCamelObject}}Model) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
query := fmt.Sprintf("select %s from %s where {{.originalPrimaryField}} = {{if .postgreSql}}$1{{else}}?{{end}} limit 1", {{.lowerStartCamelObject}}Rows, m.table ) query := fmt.Sprintf("select %s from %s where {{.originalPrimaryField}} = {{if .postgreSql}}$1{{else}}?{{end}} limit 1", {{.lowerStartCamelObject}}Rows, m.table )
return conn.QueryRowCtx(ctx, v, query, primary) return conn.QueryRowCtx(ctx, v, query, primary)
} }

@ -1,7 +1,7 @@
func (m *default{{.upperStartCamelObject}}Model) FindOneBy{{.upperField}}(ctx context.Context, {{.in}}) (*{{.upperStartCamelObject}}, error) { func (m *default{{.upperStartCamelObject}}Model) FindOneBy{{.upperField}}(ctx context.Context, {{.in}}) (*{{.upperStartCamelObject}}, error) {
{{if .withCache}}{{.cacheKey}} {{if .withCache}}{{.cacheKey}}
var resp {{.upperStartCamelObject}} var resp {{.upperStartCamelObject}}
err := m.QueryRowIndexCtx(ctx, &resp, {{.cacheKeyVariable}}, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { err := m.QueryRowIndexCtx(ctx, &resp, {{.cacheKeyVariable}}, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v any) (i any, e error) {
query := fmt.Sprintf("select %s from %s where {{.originalField}} limit 1", {{.lowerStartCamelObject}}Rows, m.table) query := fmt.Sprintf("select %s from %s where {{.originalField}} limit 1", {{.lowerStartCamelObject}}Rows, m.table)
if err := conn.QueryRowCtx(ctx, &resp, query, {{.lowerStartCamelField}}); err != nil { if err := conn.QueryRowCtx(ctx, &resp, query, {{.lowerStartCamelField}}); err != nil {
return nil, err return nil, err

@ -1,7 +1,7 @@
func (m *default{{.upperStartCamelObject}}Model) FindOne(ctx context.Context, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) (*{{.upperStartCamelObject}}, error) { func (m *default{{.upperStartCamelObject}}Model) FindOne(ctx context.Context, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) (*{{.upperStartCamelObject}}, error) {
{{if .withCache}}{{.cacheKey}} {{if .withCache}}{{.cacheKey}}
var resp {{.upperStartCamelObject}} var resp {{.upperStartCamelObject}}
err := m.QueryRowCtx(ctx, &resp, {{.cacheKeyVariable}}, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { err := m.QueryRowCtx(ctx, &resp, {{.cacheKeyVariable}}, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
query := fmt.Sprintf("select %s from %s where {{.originalPrimaryKey}} = {{if .postgreSql}}$1{{else}}?{{end}} limit 1", {{.lowerStartCamelObject}}Rows, m.table) query := fmt.Sprintf("select %s from %s where {{.originalPrimaryKey}} = {{if .postgreSql}}$1{{else}}?{{end}} limit 1", {{.lowerStartCamelObject}}Rows, m.table)
return conn.QueryRowCtx(ctx, v, query, {{.lowerStartCamelPrimaryKey}}) return conn.QueryRowCtx(ctx, v, query, {{.lowerStartCamelPrimaryKey}})
}) })

@ -71,7 +71,7 @@ func (m *defaultStudentModel) Insert(data Student) (sql.Result, error) {
func (m *defaultStudentModel) FindOne(id int64) (*Student, error) { func (m *defaultStudentModel) FindOne(id int64) (*Student, error) {
studentIdKey := fmt.Sprintf("%s%v", cacheStudentIdPrefix, id) studentIdKey := fmt.Sprintf("%s%v", cacheStudentIdPrefix, id)
var resp Student var resp Student
err := m.QueryRow(&resp, studentIdKey, func(conn sqlx.SqlConn, v interface{}) error { err := m.QueryRow(&resp, studentIdKey, func(conn sqlx.SqlConn, v any) error {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", studentRows, m.table) query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", studentRows, m.table)
return conn.QueryRow(v, query, id) return conn.QueryRow(v, query, id)
}) })
@ -88,7 +88,7 @@ func (m *defaultStudentModel) FindOne(id int64) (*Student, error) {
func (m *defaultStudentModel) FindOneByClassName(class, name string) (*Student, error) { func (m *defaultStudentModel) FindOneByClassName(class, name string) (*Student, error) {
studentClassNameKey := fmt.Sprintf("%s%v%v", cacheStudentClassNamePrefix, class, name) studentClassNameKey := fmt.Sprintf("%s%v%v", cacheStudentClassNamePrefix, class, name)
var resp Student var resp Student
err := m.QueryRowIndex(&resp, studentClassNameKey, m.formatPrimary, func(conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { err := m.QueryRowIndex(&resp, studentClassNameKey, m.formatPrimary, func(conn sqlx.SqlConn, v any) (i any, e error) {
query := fmt.Sprintf("select %s from %s where `class` = ? and `name` = ? limit 1", studentRows, m.table) query := fmt.Sprintf("select %s from %s where `class` = ? and `name` = ? limit 1", studentRows, m.table)
if err := conn.QueryRow(&resp, query, class, name); err != nil { if err := conn.QueryRow(&resp, query, class, name); err != nil {
return nil, err return nil, err
@ -124,11 +124,11 @@ func (m *defaultStudentModel) Delete(id int64, className, studentName string) er
return err return err
} }
func (m *defaultStudentModel) formatPrimary(primary interface{}) string { func (m *defaultStudentModel) formatPrimary(primary any) string {
return fmt.Sprintf("%s%v", cacheStudentIdPrefix, primary) return fmt.Sprintf("%s%v", cacheStudentIdPrefix, primary)
} }
func (m *defaultStudentModel) queryPrimary(conn sqlx.SqlConn, v, primary interface{}) error { func (m *defaultStudentModel) queryPrimary(conn sqlx.SqlConn, v, primary any) error {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", studentRows, m.table) query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", studentRows, m.table)
return conn.QueryRow(v, query, primary) return conn.QueryRow(v, query, primary)
} }

@ -27,13 +27,13 @@ type rowsScanner interface {
Columns() ([]string, error) Columns() ([]string, error)
Err() error Err() error
Next() bool Next() bool
Scan(v ...interface{}) error Scan(v ...any) error
} }
func getTaggedFieldValueMap(v reflect.Value) (map[string]interface{}, error) { func getTaggedFieldValueMap(v reflect.Value) (map[string]any, error) {
rt := mapping.Deref(v.Type()) rt := mapping.Deref(v.Type())
size := rt.NumField() size := rt.NumField()
result := make(map[string]interface{}, size) result := make(map[string]any, size)
for i := 0; i < size; i++ { for i := 0; i < size; i++ {
key := parseTagName(rt.Field(i)) key := parseTagName(rt.Field(i))
@ -63,7 +63,7 @@ func getTaggedFieldValueMap(v reflect.Value) (map[string]interface{}, error) {
return result, nil return result, nil
} }
func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([]interface{}, error) { func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([]any, error) {
fields := unwrapFields(v) fields := unwrapFields(v)
if strict && len(columns) < len(fields) { if strict && len(columns) < len(fields) {
return nil, ErrNotMatchDestination return nil, ErrNotMatchDestination
@ -74,7 +74,7 @@ func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([
return nil, err return nil, err
} }
values := make([]interface{}, len(columns)) values := make([]any, len(columns))
if len(taggedMap) == 0 { if len(taggedMap) == 0 {
for i := 0; i < len(values); i++ { for i := 0; i < len(values); i++ {
valueField := fields[i] valueField := fields[i]
@ -100,7 +100,7 @@ func mapStructFieldsIntoSlice(v reflect.Value, columns []string, strict bool) ([
if tagged, ok := taggedMap[column]; ok { if tagged, ok := taggedMap[column]; ok {
values[i] = tagged values[i] = tagged
} else { } else {
var anonymous interface{} var anonymous any
values[i] = &anonymous values[i] = &anonymous
} }
} }
@ -119,7 +119,7 @@ func parseTagName(field reflect.StructField) string {
return options[0] return options[0]
} }
func unmarshalRow(v interface{}, scanner rowsScanner, strict bool) error { func unmarshalRow(v any, scanner rowsScanner, strict bool) error {
if !scanner.Next() { if !scanner.Next() {
if err := scanner.Err(); err != nil { if err := scanner.Err(); err != nil {
return err return err
@ -161,7 +161,7 @@ func unmarshalRow(v interface{}, scanner rowsScanner, strict bool) error {
} }
} }
func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error { func unmarshalRows(v any, scanner rowsScanner, strict bool) error {
rv := reflect.ValueOf(v) rv := reflect.ValueOf(v)
if err := mapping.ValidatePtr(&rv); err != nil { if err := mapping.ValidatePtr(&rv); err != nil {
return err return err
@ -181,7 +181,7 @@ func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error {
rve.Set(reflect.Append(rve, reflect.Indirect(item))) rve.Set(reflect.Append(rve, reflect.Indirect(item)))
} }
} }
fillFn := func(value interface{}) error { fillFn := func(value any) error {
if rve.CanSet() { if rve.CanSet() {
if err := scanner.Scan(value); err != nil { if err := scanner.Scan(value); err != nil {
return err return err

@ -26,12 +26,12 @@ func NewMockConn(db *sql.DB) *MockConn {
} }
// Exec executes sql and returns the result // Exec executes sql and returns the result
func (conn *MockConn) Exec(query string, args ...interface{}) (sql.Result, error) { func (conn *MockConn) Exec(query string, args ...any) (sql.Result, error) {
return exec(conn.db, query, args...) return exec(conn.db, query, args...)
} }
// ExecCtx executes sql and returns the result // ExecCtx executes sql and returns the result
func (conn *MockConn) ExecCtx(_ context.Context, query string, args ...interface{}) (sql.Result, error) { func (conn *MockConn) ExecCtx(_ context.Context, query string, args ...any) (sql.Result, error) {
return exec(conn.db, query, args...) return exec(conn.db, query, args...)
} }
@ -47,50 +47,50 @@ func (conn *MockConn) PrepareCtx(_ context.Context, query string) (sqlx.StmtSess
} }
// QueryRow executes sql and returns a query row // QueryRow executes sql and returns a query row
func (conn *MockConn) QueryRow(v interface{}, q string, args ...interface{}) error { func (conn *MockConn) QueryRow(v any, q string, args ...any) error {
return query(conn.db, func(rows *sql.Rows) error { return query(conn.db, func(rows *sql.Rows) error {
return unmarshalRow(v, rows, true) return unmarshalRow(v, rows, true)
}, q, args...) }, q, args...)
} }
// QueryRowCtx executes sql and returns a query row // QueryRowCtx executes sql and returns a query row
func (conn *MockConn) QueryRowCtx(_ context.Context, v interface{}, query string, args ...interface{}) error { func (conn *MockConn) QueryRowCtx(_ context.Context, v any, query string, args ...any) error {
return conn.QueryRow(v, query, args...) return conn.QueryRow(v, query, args...)
} }
// QueryRowPartial executes sql and returns a partial query row // QueryRowPartial executes sql and returns a partial query row
func (conn *MockConn) QueryRowPartial(v interface{}, q string, args ...interface{}) error { func (conn *MockConn) QueryRowPartial(v any, q string, args ...any) error {
return query(conn.db, func(rows *sql.Rows) error { return query(conn.db, func(rows *sql.Rows) error {
return unmarshalRow(v, rows, false) return unmarshalRow(v, rows, false)
}, q, args...) }, q, args...)
} }
// QueryRowPartialCtx executes sql and returns a partial query row // QueryRowPartialCtx executes sql and returns a partial query row
func (conn *MockConn) QueryRowPartialCtx(_ context.Context, v interface{}, query string, args ...interface{}) error { func (conn *MockConn) QueryRowPartialCtx(_ context.Context, v any, query string, args ...any) error {
return conn.QueryRowPartial(v, query, args...) return conn.QueryRowPartial(v, query, args...)
} }
// QueryRows executes sql and returns query rows // QueryRows executes sql and returns query rows
func (conn *MockConn) QueryRows(v interface{}, q string, args ...interface{}) error { func (conn *MockConn) QueryRows(v any, q string, args ...any) error {
return query(conn.db, func(rows *sql.Rows) error { return query(conn.db, func(rows *sql.Rows) error {
return unmarshalRows(v, rows, true) return unmarshalRows(v, rows, true)
}, q, args...) }, q, args...)
} }
// QueryRowsCtx executes sql and returns query rows // QueryRowsCtx executes sql and returns query rows
func (conn *MockConn) QueryRowsCtx(_ context.Context, v interface{}, query string, args ...interface{}) error { func (conn *MockConn) QueryRowsCtx(_ context.Context, v any, query string, args ...any) error {
return conn.QueryRows(v, query, args...) return conn.QueryRows(v, query, args...)
} }
// QueryRowsPartial executes sql and returns partial query rows // QueryRowsPartial executes sql and returns partial query rows
func (conn *MockConn) QueryRowsPartial(v interface{}, q string, args ...interface{}) error { func (conn *MockConn) QueryRowsPartial(v any, q string, args ...any) error {
return query(conn.db, func(rows *sql.Rows) error { return query(conn.db, func(rows *sql.Rows) error {
return unmarshalRows(v, rows, false) return unmarshalRows(v, rows, false)
}, q, args...) }, q, args...)
} }
// QueryRowsPartialCtx executes sql and returns partial query rows // QueryRowsPartialCtx executes sql and returns partial query rows
func (conn *MockConn) QueryRowsPartialCtx(_ context.Context, v interface{}, query string, args ...interface{}) error { func (conn *MockConn) QueryRowsPartialCtx(_ context.Context, v any, query string, args ...any) error {
return conn.QueryRowsPartial(v, query, args...) return conn.QueryRowsPartial(v, query, args...)
} }
@ -113,50 +113,50 @@ func (s statement) Close() error {
return s.stmt.Close() return s.stmt.Close()
} }
func (s statement) Exec(args ...interface{}) (sql.Result, error) { func (s statement) Exec(args ...any) (sql.Result, error) {
return execStmt(s.stmt, args...) return execStmt(s.stmt, args...)
} }
func (s statement) ExecCtx(_ context.Context, args ...interface{}) (sql.Result, error) { func (s statement) ExecCtx(_ context.Context, args ...any) (sql.Result, error) {
return s.Exec(args...) return s.Exec(args...)
} }
func (s statement) QueryRow(v interface{}, args ...interface{}) error { func (s statement) QueryRow(v any, args ...any) error {
return queryStmt(s.stmt, func(rows *sql.Rows) error { return queryStmt(s.stmt, func(rows *sql.Rows) error {
return unmarshalRow(v, rows, true) return unmarshalRow(v, rows, true)
}, args...) }, args...)
} }
func (s statement) QueryRowCtx(_ context.Context, v interface{}, args ...interface{}) error { func (s statement) QueryRowCtx(_ context.Context, v any, args ...any) error {
return s.QueryRow(v, args...) return s.QueryRow(v, args...)
} }
func (s statement) QueryRowPartial(v interface{}, args ...interface{}) error { func (s statement) QueryRowPartial(v any, args ...any) error {
return queryStmt(s.stmt, func(rows *sql.Rows) error { return queryStmt(s.stmt, func(rows *sql.Rows) error {
return unmarshalRow(v, rows, false) return unmarshalRow(v, rows, false)
}, args...) }, args...)
} }
func (s statement) QueryRowPartialCtx(_ context.Context, v interface{}, args ...interface{}) error { func (s statement) QueryRowPartialCtx(_ context.Context, v any, args ...any) error {
return s.QueryRowPartial(v, args...) return s.QueryRowPartial(v, args...)
} }
func (s statement) QueryRows(v interface{}, args ...interface{}) error { func (s statement) QueryRows(v any, args ...any) error {
return queryStmt(s.stmt, func(rows *sql.Rows) error { return queryStmt(s.stmt, func(rows *sql.Rows) error {
return unmarshalRows(v, rows, true) return unmarshalRows(v, rows, true)
}, args...) }, args...)
} }
func (s statement) QueryRowsCtx(_ context.Context, v interface{}, args ...interface{}) error { func (s statement) QueryRowsCtx(_ context.Context, v any, args ...any) error {
return s.QueryRows(v, args...) return s.QueryRows(v, args...)
} }
func (s statement) QueryRowsPartial(v interface{}, args ...interface{}) error { func (s statement) QueryRowsPartial(v any, args ...any) error {
return queryStmt(s.stmt, func(rows *sql.Rows) error { return queryStmt(s.stmt, func(rows *sql.Rows) error {
return unmarshalRows(v, rows, false) return unmarshalRows(v, rows, false)
}, args...) }, args...)
} }
func (s statement) QueryRowsPartialCtx(_ context.Context, v interface{}, args ...interface{}) error { func (s statement) QueryRowsPartialCtx(_ context.Context, v any, args ...any) error {
return s.QueryRowsPartial(v, args...) return s.QueryRowsPartial(v, args...)
} }

@ -13,7 +13,7 @@ import (
const slowThreshold = time.Millisecond * 500 const slowThreshold = time.Millisecond * 500
func exec(db *sql.DB, q string, args ...interface{}) (sql.Result, error) { func exec(db *sql.DB, q string, args ...any) (sql.Result, error) {
tx, err := db.Begin() tx, err := db.Begin()
if err != nil { if err != nil {
return nil, err return nil, err
@ -48,7 +48,7 @@ func exec(db *sql.DB, q string, args ...interface{}) (sql.Result, error) {
return result, err return result, err
} }
func execStmt(conn *sql.Stmt, args ...interface{}) (sql.Result, error) { func execStmt(conn *sql.Stmt, args ...any) (sql.Result, error) {
stmt := fmt.Sprint(args...) stmt := fmt.Sprint(args...)
startTime := timex.Now() startTime := timex.Now()
result, err := conn.Exec(args...) result, err := conn.Exec(args...)
@ -65,7 +65,7 @@ func execStmt(conn *sql.Stmt, args ...interface{}) (sql.Result, error) {
return result, err return result, err
} }
func query(db *sql.DB, scanner func(*sql.Rows) error, q string, args ...interface{}) error { func query(db *sql.DB, scanner func(*sql.Rows) error, q string, args ...any) error {
tx, err := db.Begin() tx, err := db.Begin()
if err != nil { if err != nil {
return err return err
@ -102,7 +102,7 @@ func query(db *sql.DB, scanner func(*sql.Rows) error, q string, args ...interfac
return scanner(rows) return scanner(rows)
} }
func queryStmt(conn *sql.Stmt, scanner func(*sql.Rows) error, args ...interface{}) error { func queryStmt(conn *sql.Stmt, scanner func(*sql.Rows) error, args ...any) error {
stmt := fmt.Sprint(args...) stmt := fmt.Sprint(args...)
startTime := timex.Now() startTime := timex.Now()
rows, err := conn.Query(args...) rows, err := conn.Query(args...)

@ -41,7 +41,7 @@ func escape(input string) string {
return b.String() return b.String()
} }
func format(query string, args ...interface{}) (string, error) { func format(query string, args ...any) (string, error) {
numArgs := len(args) numArgs := len(args)
if numArgs == 0 { if numArgs == 0 {
return query, nil return query, nil

@ -79,14 +79,14 @@ func (m mono) createAPIProject() {
logx.Must(err) logx.Must(err)
} }
logx.Must(util.With("logic").Parse(apiLogicContent).SaveTo(map[string]interface{}{ logx.Must(util.With("logic").Parse(apiLogicContent).SaveTo(map[string]any{
"svcPkg": svcPkg, "svcPkg": svcPkg,
"typesPkg": typesPkg, "typesPkg": typesPkg,
"rpcClientPkg": rpcClientPkg, "rpcClientPkg": rpcClientPkg,
"callRPC": m.callRPC, "callRPC": m.callRPC,
}, logicFile, true)) }, logicFile, true))
logx.Must(util.With("svc").Parse(svcContent).SaveTo(map[string]interface{}{ logx.Must(util.With("svc").Parse(svcContent).SaveTo(map[string]any{
"rpcClientPkg": rpcClientPkg, "rpcClientPkg": rpcClientPkg,
"configPkg": configPkg, "configPkg": configPkg,
"callRPC": m.callRPC, "callRPC": m.callRPC,

@ -125,27 +125,27 @@ func (i *ideaConsole) Info(format string, a ...any) {
fmt.Println(msg) fmt.Println(msg)
} }
func (i *ideaConsole) Debug(format string, a ...interface{}) { func (i *ideaConsole) Debug(format string, a ...any) {
msg := fmt.Sprintf(format, a...) msg := fmt.Sprintf(format, a...)
fmt.Println(aurora.BrightCyan(msg)) fmt.Println(aurora.BrightCyan(msg))
} }
func (i *ideaConsole) Success(format string, a ...interface{}) { func (i *ideaConsole) Success(format string, a ...any) {
msg := fmt.Sprintf(format, a...) msg := fmt.Sprintf(format, a...)
fmt.Println("[SUCCESS]: ", msg) fmt.Println("[SUCCESS]: ", msg)
} }
func (i *ideaConsole) Warning(format string, a ...interface{}) { func (i *ideaConsole) Warning(format string, a ...any) {
msg := fmt.Sprintf(format, a...) msg := fmt.Sprintf(format, a...)
fmt.Println("[WARNING]: ", msg) fmt.Println("[WARNING]: ", msg)
} }
func (i *ideaConsole) Error(format string, a ...interface{}) { func (i *ideaConsole) Error(format string, a ...any) {
msg := fmt.Sprintf(format, a...) msg := fmt.Sprintf(format, a...)
fmt.Println("[ERROR]: ", msg) fmt.Println("[ERROR]: ", msg)
} }
func (i *ideaConsole) Fatalln(format string, a ...interface{}) { func (i *ideaConsole) Fatalln(format string, a ...any) {
i.Error(format, a...) i.Error(format, a...)
os.Exit(1) os.Exit(1)
} }
@ -160,7 +160,7 @@ func (i *ideaConsole) Must(err error) {
} }
} }
func println(msg interface{}) { func println(msg any) {
value, ok := msg.(aurora.Value) value, ok := msg.(aurora.Value)
if !ok { if !ok {
fmt.Println(msg) fmt.Println(msg)
@ -177,27 +177,27 @@ func println(msg interface{}) {
var defaultConsole = &colorConsole{enable: true} var defaultConsole = &colorConsole{enable: true}
func Success(format string, a ...interface{}) { func Success(format string, a ...any) {
defaultConsole.Success(format, a...) defaultConsole.Success(format, a...)
} }
func Info(format string, a ...interface{}) { func Info(format string, a ...any) {
defaultConsole.Info(format, a...) defaultConsole.Info(format, a...)
} }
func Debug(format string, a ...interface{}) { func Debug(format string, a ...any) {
defaultConsole.Debug(format, a...) defaultConsole.Debug(format, a...)
} }
func Warning(format string, a ...interface{}) { func Warning(format string, a ...any) {
defaultConsole.Warning(format, a...) defaultConsole.Warning(format, a...)
} }
func Error(format string, a ...interface{}) { func Error(format string, a ...any) {
defaultConsole.Error(format, a...) defaultConsole.Error(format, a...)
} }
func Fatalln(format string, a ...interface{}) { func Fatalln(format string, a ...any) {
defaultConsole.Fatalln(format, a...) defaultConsole.Fatalln(format, a...)
} }

Loading…
Cancel
Save