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

How to convert string to Int type in golang

尚
Original
2020-01-02 09:33:563912browse

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)

Convert string to int64 :

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

int to string:

string := strconv.Itoa(int)

int64 to string:

string := strconv.FormatInt(int64,10)

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!

Statement:
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