Comments (2)
This also fails:
package main
import (
"fmt"
"github.com/spf13/cast"
)
type BusinessStatus string
func main() {
var BusinessStatusInactive BusinessStatus = "Inactive"
fmt.Printf("message should be(%s), but cast returns (%s)\n", BusinessStatusInactive, cast.ToString(BusinessStatusInactive))
}
from cast.
Nevermind, I read the README and see you don't go that far, but I'd argue you should at least make an attempt in this case... It's pretty trivial.
For anyone else that has this issue, implement a String()
function, like this:
func (o BusinessStatus) String() string {
switch o {
case BusinessStatusInactive:
return "Inactive"
case BusinessStatusInvited:
return "Invited"
case BusinessStatusActive:
return "Active"
case BusinessStatusBlocked:
return "Blocked"
default:
return ""
}
}
from cast.
Related Issues (20)
- json.Number support act like string=>int64, instead of float64=>int64
- Urgent Bug: github.com/frankban/quicktest references LGPL license HOT 2
- Add function to cast `interface{}` to `[]float64` HOT 1
- Add IntTobytes
- Unexpected results with padded strings HOT 3
- cast.tobool uint support HOT 1
- memory cost maybe big
- cast.ToInt not parsing float like string
- byte to int? HOT 1
- Can I convert to a pointer type?
- Why not support []uint64 type in ToStringSliceE function?
- cast toint32 but return zero
- cast typedefed value to uint failed HOT 2
- cast.ToInt("25.400") returned 0 HOT 2
- numeric type cast Support json.Number HOT 1
- cast.ToUint64("14017652235894064730") return 0 HOT 2
- cast.ToInt64E("") returns error while cast.ToInt64E(nil) doesn't
- cast.ToInt("08") return 0 and so on HOT 2
- Cannot cast alias variable to int32
- ToInt have bad case HOT 1
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 cast.