What is math.Floor() Function in Golang

Golang math.Floor() function - How to Use it

The math.Floor() is a built-in Golang function that returns the greatest integer value less than or equal to the specified number. The Floor() function helps us find a decimal number’s rounded-down or floor value. How to use math.Floor() function? To use the math.Floor() function, import a math package. Add a math package at the top of your … Read more

How to Convert Golang Float to Int

How to Convert Golang Float to Int

To convert a float to int in Golang, use the int() function. The int() is a built-in function that accepts an argument and returns the integer representation of the input value. When converting a floating point to an integer value, pass a float value to the int() function, and it returns an integer value. package main import … Read more

How to Check and Print Datatype in Golang

How to Print Data Type in Golang Console

To print a type in Golang, you can use the %T verb in the fmt.Printf() function. The fmt.Printf() is a built-in function that formats and writes to standard output. Example package main import ( “fmt” ) func main() { var_data := “KB19” fmt.Printf(“The type of variable is : %T\n”, var_data) } Output The type of variable is … Read more

What is Golang’s int64 Type

What is Golang's int64 Type

Golang int64 is a 64-bit signed integer ranging from -9223372036854775808 to 9223372036854775807. The int64 only stores signed numeric values composed of up to 64 bits. Golang has an int data type for numeric values. An int data type will only store signed numeric values. Integers are like their mathematical counterpart numbers without a decimal component. Saving string … Read more

How to Append a Slice in Golang

How to Append a Slice in Golang

To append a slice in Golang, you can use the append() function. This is a built-in function that appends any number of elements to the end of a slice and returns the updated slice. How does append() work in Golang The append() function doesn’t modify the original slice but creates a new slice, copies all the … Read more

What is reflect.TypeOf() Function in Golang

Golang reflect.TypeOf - How to Find Data Type in Go

The reflect.TypeOf() is a built-in Golang function that returns the data type of a variable. The function accepts a variable as an argument and returns a runtime data type. To find a variable’s data type in Golang, you can use the reflect.TypeOf() function. Syntax func TypeOf(i interface{}) Type Parameters The TypeOf() function takes only one parameter, which … Read more

How to Convert Golang int64 to String

How to Convert Golang int64 to String

To convert int64 to string in Golang, you can use the strconv.FormatInt() function. The FormatInt() function returns a string representation of a given integer in a chosen base, ranging from 2 to 36). It accepts an integer and base as arguments and returns a string representation of int64. The strconv package provides functions and utilities … Read more

Golang Itoa: How to Use strconv.Itoa() Function

Golang Itoa - How to use strconv.Itoa() Function

The strconv.Itoa() is a built-in Golang function that returns the string representation of the input value when the base is 10. The syntax of the strconv.Itoa function is this: strconv.Itoa(i int) string. The Itoa() function accepts an integer as an argument and returns a string representation of the argument. The strconv.Itoa() function is to similar … Read more

What is strconv.FormatInt() Function in Golang

Golang FormatInt - strconv.FormatInt() Function Guide

The strconv.FormatInt() is a built-in Golang function that converts an integer data type to a string data type. The FormatInt() function accepts an integer and converts based on the base value, returning a string data type value. Syntax func FormatInt(i int64, base int) string Arguments The FormatInt() takes an int64 as an argument to be converted … Read more

How to Convert ASCII to Rune in Golang

Golang ASCII to Rune - How to Convert Code Point to Char

To convert an ASCII to Rune in Golang, you can use the string() function. Rune slice is re-grouping of byte slice so that each index is a character. A rune slice appends and modifies characters with no errors. ASCII in Golang is a character encoding standard for representing text-based information with numbers. ASCII is a code that … Read more