Golang Program to print different types of values

February 25, 2022, Learn eTutorial

For a better understanding of this example, we always recommend you to learn the basic topics of Golang programming listed below:

What are the different types of values in Go language

A  coded object that involves memory allocation directly where it is created is called a data type or type of values in a computer programming language. Golang data types are basic data types of numbers, characters, boolean, etc., and composite data types that are user-defined data types built using basic data types like int, float, etc. 

How to display different types of values in Go Program

We are using fmt.println() function for printing the string to the output screen. Here we are showing how to print different types of values in the Go language. Different types of values like strings, integers, floats, booleans using fmt.println(). Given below are the steps which are used in the Go program. 


STEP 1: Import the package fmt

STEP 2: Start function main()

STEP 3: Display different values like strings, integers, floats, booleans using fmt.println()

Golang Source Code

                                          package main
import "fmt"
func main() {

    fmt.Println("hii" + "sir")
    fmt.Println("1+2 =", 1+2)
    fmt.Println("7.0/3.0 =", 7.0/3.0)
    fmt.Println(true && false)
    fmt.Println(true || false)


1+2 = 3
7.0/3.0 = 2.3333333333333335