Sprintf shows <number: 19> instead of 9

In my code I’m getting a js.Vale that is a simple object {“Age”:19}

For displaying it, I used:

data := fmt.Sprintf("Age: %v, value.Get("age"))
fmt.Println(data)

But the output was:

Age: <number: 19> 

Expected output is:

Age: 19 

Once I replaced the %v by %d to be:

data := fmt.Sprintf("Age: %v, value.Get("age"))
fmt.Println(data)

I got:

Age: {[] 4626041242239631360 0}

Get still returns a Value.

You probably want to call Int on it if you are sure it’s a number.

1 Like

what is the ‘value.Get(“age”)’ return type ?
you propably need to marshal the type to struct first.