Closed BrianMwangi21 closed 2 years ago
you can do the trick like that:
declare a method to get the float32 pointer
func floatPtr(f float32) *float32 {
return &f
}
and then:
Temperature: floatPtr(0.45)
Thanks @3l0w.
Yes this requires a pointer parameter because the "empty" value for a float of "0" has a different meaning than a nil
pointer. There is a helper for this for ints but would be nice to add for floats too but you can certainly write your own function as mentioned above.
You can assign to a local variable before and then pass the pointer like this:
temperature := 0.45
Temperature: &temperature,
Hi there,
So I am trying to add the Temperature in the CompletionRequest as shown below :
Temperature: float32(0.45),
However, when I try to run the file, the error I receive is the following :
cannot use float32(0.45) (type float32) as type *float32 in field value
Can someone help me the value that is expected in the Temperature field ? Thanks.