How to get length of a number in golang?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

To get length of a number, convert integer to string using strconv.Itoa() method then use len() method it will count and return number of integer elements.

In golang the len() method used for counts elements.

Let’s start

package main
import (

func main() {
  num := 847883663;
	fmt.Println("Length of number", len(strconv.Itoa(num)))

In the above program, we are accessing length of number, let’s see the output.


Length of number 9

Try it yourself

All the best 👍

Premium Content

You can get all the below premium content directly in your mail when you subscribe us


Interview Questions

Soon You will get CSS, JavaScript, React Js, and TypeScript So Subscribe to it.

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

Related Posts