'Golang - Type decimal.Decimal convert
Trying to convert type decimal.Decimal to string
func main() {
a := strconv.Itoa(Price) // Price of type decimal.Decimal
fmt.Printf("%q\n", a)
}
Problem: cannot use (variable of type decimal.Decimal) as int value in argument to strconv.Itoa (compile)go-staticcheck
Example code that works will be apreciated
Solution 1:[1]
Price is decimal.Decimal not int. strconv.Itoa accepts int.
From docs https://pkg.go.dev/github.com/shopspring/decimal#Decimal.String
use .String().
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lucas Katayama |
