strconv.Itoa() expects a value of type int, so you have to give it that:

log.Println("The amount is: " + strconv.Itoa(int(charge.Amount)))

But know that this may lose precision if int is 32-bit (while uint64 is 64), also sign-ness is different. strconv.FormatUint() would be better as that expects a value of type uint64:

log.Println("The amount is: " + strconv.FormatUint(charge.Amount, 10))

For more options, see this answer: Golang: format a string without printing?

If your purpose is to just print the value, you don't need to convert it, neither to int nor to string, use one of these:

log.Println("The amount is:", charge.Amount)
log.Printf("The amount is: %d\n", charge.Amount)
Answer from icza on Stack Overflow
🌐
Go Packages
pkg.go.dev › strconv
strconv package - strconv - Go Packages
FormatInt returns the string representation of i in the given base, for 2 <= base <= 36. The result uses the lower-case letters 'a' to 'z' for digit values >= 10. ... package main import ( "fmt" "strconv" ) func main() { v := int64(-42) s10 := strconv.FormatInt(v, 10) fmt.Printf("%T, %v\n", s10, s10) s16 := strconv.FormatInt(v, 16) fmt.Printf("%T, %v\n", s16, s16) }
🌐
YourBasic
yourbasic.org › golang › convert-int-to-string
Convert between int, int64 and string · YourBasic Go
var n int64 = 97 s := strconv.FormatInt(n, 16) // s == "61" (hexadecimal) Use strconv.Atoi to parse a decimal string to an int.
Discussions

go - How to convert uint64 to string - Stack Overflow
I am trying to print a string with a uint64 but no combination of strconv methods that I use is working. More on stackoverflow.com
🌐 stackoverflow.com
How to convert an int value to string in Go? - Stack Overflow
If you need to convert an int value to string, you can use faiNumber package. faiNumber is the fastest golang string parser library. All of faiNumber's function was benchmark to run way faster than the strconv package. faiNumber supports converting an int32, uint32, int64, or uint64 value to ... More on stackoverflow.com
🌐 stackoverflow.com
go - Golang converting string to int64 - Stack Overflow
I want to convert a string to an int64. What I find from the strconv package is the Atoi function. It seems to cast a string to an int and return it: // Atoi is shorthand for ParseInt(s, 10, 0). f... More on stackoverflow.com
🌐 stackoverflow.com
GMS "unable to convert string "" to int64" Error, Not Trying to convert Anything
Solution: An unrelated var was set to "", the error code did not point this out as the issue. As an addage I did clean the runner but that did not solve the issue, I also attempted restarting GM and my PC, these did not solve the issue, converting the fert00have="" to fert00have=0 solved the issue despite these vars not being directly related or ever "referring" or being dependent. More on reddit.com
🌐 r/gamemaker
1
2
December 1, 2021
🌐
Reddit
reddit.com › r/golang › the risks of converting int64 to string using a combination of "int()" and "strconv.itoa"
r/golang on Reddit: The risks of converting int64 to string using a combination of "int()" and "strconv.Itoa"
January 27, 2023 -

I've been reading some articles online why converting an int64 value to string using a combination of int() and strconv.Itoa isn't really a good idea but I am having issues trying to really grasp what it's all about. I understand there could be some inconsistencies during the conversion process but I am unable to grasp why such inconsistency could happen. I'll really appreciate it if some can explain to me like I am 5. A sample of what I am referring to can be seen below. Thanks

var amt int64 = 90 
strconv.Itoa(int(amt))
🌐
ByteSizeGo
bytesizego.com › blog › convert-int-to-string-golang
How to convert an int to string in Golang
This is especially useful when you are working with larger integer types and need to convert them to strings with a specified base (for example, base 10 for decimal or base 16 for hexadecimal). package main import ( "fmt" "strconv" ) func main() { number := int64(789) str := strconv.FormatInt(number, 10) // Base 10 conversion fmt.Println("Formatted string:", str) } strconv.Itoa(): Best for simple and efficient conversion of integers to strings without additional formatting.
🌐
Golang Docs
golangdocs.com › home › golang int64 to string conversion
Golang int64 to string conversion - Golang Docs
August 19, 2022 - If you have to convert int64 to string, use strconv.Itoa() function.
Find elsewhere
🌐
Go language Tutorial
golangtutorial.dev › home › tips › how to convert an int32 & int64 to string in go
How to Convert an int32 & int64 to string in Go - Go language Tutorial
November 5, 2020 - To Convert an int to string in Go use strconv.Itoa()(int32 to string) and strconv.FormatInt()(int64 to string) functions which are part of Go's strconv package
🌐
Programming.Guide
programming.guide › go › convert-int64-to-string.html
Go: Convert int64 to string | Programming.Guide
To decimal string: n := int64(32) str := strconv.FormatInt(n, 10) fmt.Println(str) // Prints "32" To hexadecimal string: n := int64(32) str := strconv.FormatInt(n, 16) fmt.Println(str) // Prints "20" Be the first to comment!
🌐
Sentry
sentry.io › sentry answers › go › converting an int to a string in go
Converting an Int to a String in Go | Sentry
October 15, 2024 - func main() { i := int64(123) fmt.Println(strconv.FormatInt(i, 16)) }
🌐
Ecostack
ecostack.dev › posts › golang-int-to-string
Golang Integer to String · Ecostack
August 8, 2023 - Internally, it is calling the FormatInt ... strconv.Itoa(i) fmt.Printf("%T %v\n", s, s) } ... The strconv.FormatInt(i int64, base int) function converts an integer to a string....
🌐
php.cn
m.php.cn › home › backend development › golang › how to convert int64 to string in go language
How to convert int64 to string in go language-Golang-php.cn
January 27, 2021 - //string到int int,err:=strconv.Atoi(string) //string到int64 int64, err := strconv.ParseInt(string, 10, 64) //int到string string:=strconv.Itoa(int) //int64到string string:=strconv.FormatInt(int64,10) //string到float32(float64) float,err ...
🌐
GeeksforGeeks
geeksforgeeks.org › go language › different-ways-to-convert-an-integer-variable-to-string-in-golang
Different Ways to Convert an Integer Variable to String in Golang - GeeksforGeeks
April 28, 2025 - // Go program to illustrate // How to convert integer // variable into String package main import ( "fmt" "strconv" ) //Main Function func main() { i := -32 s := strconv.FormatInt(int64(i) , 7) fmt.Printf("Type : %T \nValue : %v\n", s, s) }
🌐
ZetCode
zetcode.com › golang › inttostring
Go int to string conversion
package main import ( "fmt" "strconv" ) func main() { var file_size int64 = 1544466212 file_size_s := strconv.FormatInt(file_size, 10) msg := "The file size is " + file_size_s + " bytes" fmt.Println(msg) }
🌐
Golang.cafe
golang.cafe › blog › golang-int-to-string-conversion-example
Golang Int To String Conversion Example | Golang.cafe
April 27, 2022 - Let’s see an example on how we can use these functions to convert an integer to an ASCII string · package main import ( "fmt" "strconv" ) func main() { i := 10 s1 := strconv.FormatInt(int64(i), 10) s2 := strconv.Itoa(i) fmt.Printf("%v, %v\n", s1, s2) }
🌐
gosamples
gosamples.dev › tutorials › convert int to string in go
🔢 Convert int to string in Go
July 23, 2021 - number := 12 str := strconv.Itoa(number) fmt.Println(str) var number int64 = 12 // you can use any integer here: int, int32, int16, int8 str := strconv.FormatInt(number, 16) fmt.Println(str)
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-convert-data-types-in-go
How To Convert Data Types in Go | DigitalOcean
May 9, 2019 - Strings can be converted to numbers by using the strconv package in the Go standard library. The strconv package has functions for converting both integer and float number types. This is a very common operation when accepting input from the user. For example, if you had a program that asked ...