What is the strconv.ErrRange variable in Golang?
Overview
In Go, the ErrRange variable is a built-in variable of the strconv package, which indicates that a given value is out of range for the target type. It takes no parameters.
Syntax
*errors.errorString strconv.ErrRange
var ErrRange = errors.New("value out of range")
Return type
The return type of this variable is *errors.errorString.
Return value
This variable returns the "value out of range" string.
Example
package mainimport ("fmt""strconv")func main() {//Display the return typefmt.Printf("The return type of strconv.ErrRange is %T\n", strconv.ErrRange)// Display the return valuefmt.Println("the return value of strconv.ErrRange:", strconv.ErrRange)}
Explanation
-
Line 1: We add the
mainpackage. -
Lines 3–6: We import the other required packages.
-
Line 8: We define the
main()function. -
Line 10: We print the return type of the
strconv.ErrSyntaxvariable. -
Line 12: We print the return value of the
strconv.ErrSyntaxvariable.