Hi, I'm Jioby 🎉
- 🇨🇳 Chinese
- 📝 https://shockerli.net
- 🥬 The self-cultivation of leek stems
Easy and safe convert any value to another type in Go. (Go 数据类型安全转换)
Home Page: https://cvt.shockerli.net
License: MIT License
请问这段代码运行结果是否应该返回error
因为实际他的值已经不是原来的值了
fmt.Println(cvt.IntE("12.1")) // 12 <nil>
fmt.Println(strconv.ParseInt("12.1", 10, 64)) // 0 strconv.ParseInt: parsing "12.1": invalid syntax
指万恶的protobuf,所有的接口都是指针,
这样类型转换就要套两层
proto.Uint32(cvt.Uint32(xxx))
希望能有一套接口能直接完成这个转换
cvt.Uint32P(xxx)
万谢
func StringMapE(val interface{}) (m map[string]interface{}, err error)
// input
`{"name":"cvt","age":3.21}`
// expect
map[string]interface{}{"name": "cvt", "age": 3.21}
map
type// input
map[interface{}]interface{}{111: "cvt", "222": 3.21}
// expect
map[string]interface{}{"111": "cvt", "222": 3.21}
struct
type// input
struct {
Name string
Age int
}{"cvt", 3}
// expect
map[string]interface{}{"Name": "cvt", "Age": 3}
妈呀,终于找到这种库了,有了这个库,岂不是可以像写Python一样随意转换了😃
package main
import (
"fmt"
"github.com/shockerli/cvt"
)
func main() {
fmt.Print("7138826985640367621", "\n")
fmt.Print(cvt.Int64("7138826985640367621"), "\n")
}
输出
7138826985640367621
7138826985640368128
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.