Go Package strconv: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=External= * https://pkg.go.dev/strconv =Internal= * Standard library =Overview=")
 
 
(6 intermediate revisions by the same user not shown)
Line 4: Line 4:
=Internal=
=Internal=
* [[Go_Language_Modularization#strconv|Standard library]]
* [[Go_Language_Modularization#strconv|Standard library]]
* [[Go_Strings#Conversion_with_strconv_Functions|Go Strings]]


=Overview=
=Overview=
The <code>strconv</code> package contains functions to convert strings to and from other data types.
=Functions=
====<tt>Atoi()</tt>====
{{External|https://pkg.go.dev/strconv#Atoi}}
ASCII-to-int, converts a string representation of an integer to an <code>int</code> type.
<syntaxhighlight lang='go'>
import "strconv"
a := "15"
b, error := strconv.Atoi(a)
println(b, error)
</syntaxhighlight>
====<tt>Itoa()</tt>====
{{External|https://pkg.go.dev/strconv#Itoa}}
Converts an integer to its string representation.
====<tt>FormatFloat()</tt>====
{{External|https://pkg.go.dev/strconv#FormatFloat}}
====<tt>ParseFloat()</tt>====
{{External|https://pkg.go.dev/strconv#ParseFloat}}

Latest revision as of 04:41, 22 August 2023

External

Internal

Overview

The strconv package contains functions to convert strings to and from other data types.

Functions

Atoi()

https://pkg.go.dev/strconv#Atoi

ASCII-to-int, converts a string representation of an integer to an int type.

import "strconv"

a := "15"
b, error := strconv.Atoi(a)
println(b, error)

Itoa()

https://pkg.go.dev/strconv#Itoa

Converts an integer to its string representation.

FormatFloat()

https://pkg.go.dev/strconv#FormatFloat

ParseFloat()

https://pkg.go.dev/strconv#ParseFloat