Questions tagged [strconv]
29 questions
79
votes
6 answers
How to convert uint64 to string
I am trying to print a string with a uint64 but no combination of strconv methods that I use is working.
log.Println("The amount is: " + strconv.Itoa((charge.Amount)))
Gives me:
cannot use charge.Amount (type uint64) as type int in argument to…

Anthony
- 13,434
- 14
- 60
- 80
28
votes
2 answers
strconv.Atoi() throwing error when given a string
When trying to use strconv on a variable passed via URL(GET variable named times), GoLang fails on compilation stating the following:
multiple-value strconv.Atoi() in a single-value context
However, when I do reflect.TypeOf I get string as the…

dead beef
- 673
- 2
- 6
- 20
7
votes
2 answers
How to add single-quotes to strings in Golang?
Perhaps this is an easy question, but I haven't figured out how to do this:
I have a string slice in Go, which I would like to represent as a comma-separated string. Here is the slice example:
example := []string{"apple", "Bear", "kitty"}
And I…

EB2127
- 1,788
- 3
- 22
- 43
4
votes
1 answer
How to convert an HTML form value into an int in Golang
My test Handler code is here:
func defineHandler(w http.ResponseWriter, r *http.Request) {
a := strconv.ParseInt(r.FormValue("aRows")[0:], 10, 64);
b := r.FormValue("aRows");
fmt.Fprintf(w, "aRows is: %s", b);
}
The error returned…

user2628946
- 103
- 2
- 6
2
votes
2 answers
Golang Gin retrieve integer data
I'm trying to retrieve int data from POST requisitions with Gin, but I'm getting an error saying that the functions (PostForm, or any other) expects strings as arguments. I've tried to search for a function expecting int content, but with no…

Vinicius Mocci
- 99
- 3
- 12
2
votes
1 answer
Float64 type printing as int in Golang
Surprisingly I couldn't find anyone else having this same issue; I tried simply initializing a float64 in Go and printing it, then attempting a string conversion and printing that. Neither output was accurate.
I've attempted this with many…

Andrew
- 357
- 5
- 16
2
votes
1 answer
Is there a Java (Android) equivalent to VB6 Strconv
I have the following in an old VB6 class that I need to move to a Java class in Android.
tmp = StrConv(vValue, vbUnicode, AESLOCALE)
tmp = StrConv(vData, vbFromUnicode, AESLOCALE)
where AESLOCALE is 1033
I have had a hunt around but cannot seem…

Mark Anderson
- 330
- 3
- 14
2
votes
1 answer
String to Float64: multiple-value strconv.ParseFloat() in single-value context
I have an array of STRING slices like this:
[[header1 header2 startdate enddate header3 header4]
[item1 100 01/01/2017 02/01/2017 5343340.56343 3.77252223956]
[item2 554 01/01/2017 02/01/2017 22139.461201388 17.232284405]]
Keep in mind that the…

shishh03
- 57
- 4
- 14
2
votes
2 answers
Idiomatic way to use strconv.ParseInt with ints
I end up writing code like this. I need a regular int (for some other function call), but parseInt only produces 64 bit ints:
i64, err := strconv.ParseInt(s, 10, 0)
if err != nil {
fmt.Println("parsing failed for", s)
}
i :=…

Eve Freeman
- 32,467
- 4
- 86
- 101
1
vote
2 answers
VBA StrConv with vbNarrow throw Run-time eror '5'
I have an excel file which work well with Excel 2007, now my company upgrade all PC to Windows 10 Enterprise v1809 and Office 2016, then it got error runtime error 5.
Here is my code, the error throw from StrConv line,
Tried Google but no help, is…

Luke
- 1,623
- 3
- 24
- 32
1
vote
1 answer
How to embed html inside json in a format that Sendgrid API accepts?
I have been trying to send an HTML email using the Sendgrid API, but I have been unsuccessful in embedding the html inside the json request.
This is an example of the html I am trying to send (emailtpl):

Darian Hickman
- 853
- 10
- 26
1
vote
1 answer
Special characters and StrConv
i have an xls with text in different languages, which include also german, greek, and so on.
I have to copy these texts to a html file.
The resulting text is not shown as expected, with special characters, like umlauts or greek characters.
For…
1
vote
1 answer
Convert a byte array to float64
I am trying to convert a byte-array read from a file, which actually happens to be a float. I can go ahead and use strconv.ParseFloat but I am wondering if there is any faster way to achieve this, rather than this string conversion overhead?
The…

ansrivas
- 597
- 2
- 9
- 14
1
vote
1 answer
1
vote
2 answers
Parse number string digits
I am trying to calculate the multiplication result of a few digits which are part of a long digits string. Here is my code:
package main
import (
"fmt"
"strconv"
)
func main() {
inputNum := "73167176531330624919225119"
mult :=…

Shai Aharoni
- 1,955
- 13
- 25