Comments (7)
from go-zero.
from go-zero.
from go-zero.
Bot detected the issue body's language is not English, translate it automatically. π―ππ»π§βπ€βπ§π«π§πΏβπ€βπ§π»π©πΎβπ€βπ¨πΏπ¬πΏ
from go-zero.
func convertTypeFromString(kind reflect.Kind, str string) (any, error) {
switch kind {
case reflect.Bool:
switch strings.ToLower(str) {
case "1", "true":
return true, nil
case "0", "false":
return false, nil
default:
return false, errTypeMismatch
}
case reflect.Int:
return strconv.ParseInt(str, 10, intSize)
case reflect.Int8:
return strconv.ParseInt(str, 10, 8)
case reflect.Int16:
return strconv.ParseInt(str, 10, 16)
case reflect.Int32:
return strconv.ParseInt(str, 10, 32)
case reflect.Int64:
return strconv.ParseInt(str, 10, 64)
case reflect.Uint:
return strconv.ParseUint(str, 10, intSize)
case reflect.Uint8:
return strconv.ParseUint(str, 10, 8)
case reflect.Uint16:
return strconv.ParseUint(str, 10, 16)
case reflect.Uint32:
return strconv.ParseUint(str, 10, 32)
case reflect.Uint64:
return strconv.ParseUint(str, 10, 64)
case reflect.Float32:
return strconv.ParseFloat(str, 32)
case reflect.Float64:
return strconv.ParseFloat(str, 64)
case reflect.String:
return str, nil
default:
return nil, errUnsupportedType
}
}
So when I specify a field which type is []any, the element in this any slice should check data type twice in convertTypeFromString
, or it will return error
from go-zero.
json.Number implements the fmt.Stringer interface, so it is treated as a string, and the received type is interface{}, but convertTypeFromString obviously does not support interface. This has always been explained, and even the API syntax does not Any and interface{} types are supported, so we do not consider this issue an issue.
from go-zero.
So if we want to declare a variable of type []any in the request body, go-zero cannot match the need?
from go-zero.
Related Issues (20)
- gateway how to config cors function
- grpc error management like kratos error generator HOT 3
- Add a flag to whether to generate pb file HOT 1
- API Import generate questions HOT 6
- Need a customized.tpl file which includes all the template Execute variables. HOT 1
- I want to print log to file. But I already want to see it in console. HOT 6
- Any plan to support rocketmq? HOT 2
- Use gateway server.AddRoute(), The limit(MaxConns) of this route does not take effect HOT 3
- how to exec my own middleware before build-in jwt? HOT 1
- A RPC service generated by multiple proto files? HOT 3
- How to make gracefulStop waiting? HOT 8
- 'circuit breaker is open','last resolver error: produced zero addresses' HOT 3
- Suggest to add option to disable parameter validation HOT 1
- How to set the part of request params nil ? HOT 1
- Error: sh: goctl-swagger: command not found HOT 1
- How to report trace data to the Monitor of jaeger?
- bug on sql concatenation HOT 2
- Is it possible to support interface in goctl? HOT 1
- Using gateway timeout error, directly go to grpc successfully HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-zero.