String Formatting in Golang

Create new folder named src. In src folder, create new file named main.go as below:

package main

import "fmt"

func main() {

	var age int = 20
	var fullName string = "abc"
	var status bool = true
	var price float32 = 4.5
	var key rune = 'B'

	fmt.Printf("age: %d\n", age)
	fmt.Printf("full name: %s\n", fullName)
	fmt.Printf("status: %t\n", status)
	fmt.Printf("price: %1.1f\n", price)
	fmt.Printf("key: %c and position in ASCII: %d\n", key, key)

}




Open Terminal windows in Visual Studio Code and run command line: go run main.go

age: 20
full name: abc
status: true
price: 4.5
key: B and position in ASCII: 66