Hi, I have
type Product struct {
Weight json.Number
}
func (p Product) GetWeight() float64 {
tmp, _ := p.Weight.Float64()
return tmp
}
I would like to be able to call and assign the variable directly. I got the GetWeight() to help me convert from json.Number to float64.
How to assign the variable?
I would like to be able to use
p Product
&p.Weight
Can some one help me or simplify the GetWeight also maybe?
because right now I can only do it by:
var tempWeight float32
assign using &tempWeight
then
p.Product = json.Number(fmt.Sprintf("%f", tempWeight))
Thank you.