Home > Backend Development > Golang > How to implement string conversion to int in go language

How to implement string conversion to int in go language

藏色散人
Release: 2023-01-11 09:23:29
Original
3858 people have browsed it

The method of converting string to int in Go language: 1. Convert string to int through "int, err:=strconv.Atoi()" method; 2. Convert string to int through "int64, err:=strconv.ParseInt. .." method converts string to int64.

How to implement string conversion to int in go language

The operating environment of this article: Windows7 system, Go1.11.2, Dell G3 computer.

Recommended: "golang tutorial"

How to convert strings to various int types in golang

Go language implements string conversion int

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

Attachment:

int to string:

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

int64 to string:

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

The above is the detailed content of How to implement string conversion to int in go language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template