How to use strconv package

The strconv package provides functions to convert strings to integers, floats, and booleans, and vice versa.

The strconv package converts strings to and from basic data types like integers, floats, and booleans.

import "strconv"

// String to int
num, err := strconv.Atoi("42")

// Int to string
s := strconv.Itoa(100)

// String to float
f, err := strconv.ParseFloat("3.14", 64)

// String to bool
b, err := strconv.ParseBool("true")