Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

golang
strconv
communitycreator

What is the strconv.ErrRange variable in Golang?

Maria Elijah

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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 main
import (
"fmt"
"strconv"
)
func main() {
//Display the return type
fmt.Printf("The return type of strconv.ErrRange is %T\n", strconv.ErrRange)
// Display the return value
fmt.Println("the return value of strconv.ErrRange:", strconv.ErrRange)
}

Explanation

  • Line 1: We add the main package.

  • 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.ErrSyntax variable.

  • Line 12: We print the return value of the strconv.ErrSyntax variable.

RELATED TAGS

golang
strconv
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring