Home > Backend Development > Golang > How to convert string to Int type in golang

How to convert string to Int type in golang

Release: 2020-01-02 09:33:56
Original
3960 people have browsed it

How to convert string to Int type in golang

How to convert strings to various int types in golang:

Convert string to int:

int, err := strconv.Atoi(string)
Copy after login

Convert string to int64 :

int64, err := strconv.ParseInt(string, 10, 64)
Copy after login

int to string:

string := strconv.Itoa(int)
Copy after login

int64 to string:

string := strconv.FormatInt(int64,10)
Copy after login

For more golang knowledge, please pay attention to the golang tutorial column.

The above is the detailed content of How to convert string to Int type in golang. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
How to choose golang web mvc framework
From 1970-01-01 08:00:00
0
0
0
Is it necessary to use nginx when using golang?
From 1970-01-01 08:00:00
0
0
0
golang - vim plug-in to write go
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template