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

How to convert string to int in go language

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

How to convert string to int in go language: First create a go sample file; then convert string to int through the "int, err := strconv.Atoi(string)" method.

How to convert string to int in go language

Environment of this article: Windows 7 system, Go1.11.2 version, this article is applicable to all brands of computers.

Recommendation: "golang tutorial"

Conversion between string and int types in golang

Summarizes the mutual conversion methods between strings and various int types in golang:

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)
Copy after login

For more related technical articles, please visit the go language column!

The above is the detailed content of How to convert string 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