Could someone please tell me if go supports automatic casting of numeric types. Right now I have to manually convert the results of all my computation to int or int64 and keep track of what numeric type I am using.
相关问题
- Golang mongodb aggregation
- How to flatten out a nested json structure in go
- how to install private repo using glide golang
- How to convert a string to a byte array which is c
- Dynamic Casts or Function Overloads?
相关文章
- Can I run a single test in a suite?
-
What is the difference between
and in java - How to check if a request was cancelled
- Is it possible to implement an interface with unex
- Why do I have to cast enums to int in C#?
- How to access value of first index of array in Go
- Embedded Interface
- React Native Input component takes ony numeric val
Go won't convert numeric types automatically for you.
From the language specification:
You have to convert between types manually, e.g.
Go does not support implicit type conversions in numeric type.
Refer spec. I think this is for reasons of safety and predictability. One more thing I found was a bit weird/interesting is that you cant even convert from int to int32 implicitly, which is weird cause both are of the same size.