xxxxxxxxxx
// Program to illustrate the use of Println() function
package main
import ("fmt")
// prints output in different lines
func main() {
currentSalary := 50000
fmt.Println("Hello")
fmt.Println("World!")
fmt.Println("Current Salary:", currentSalary)
}
xxxxxxxxxx
// Program to illustrate fmt.Print()
package main
// importing the fmt package
import ("fmt")
func main() {
fmt.Print("Hello, ")
fmt.Print("World!")
}
xxxxxxxxxx
package main
import ("fmt")
func main() {
var number int
fmt.Scanf("%d", &number) // Input: 10
fmt.Printf("%d", number) // Output: 10
}
xxxxxxxxxx
// Program to illustrate Print() function
package main
import "fmt"
// prints output in same lines
func main() {
name := "Chandler Bing"
fmt.Print("Hello", name)
fmt.Print("Welcome to Go Programming")
}
xxxxxxxxxx
name := "Leslie"
fmt.Printf("My name is %v", name)
// My name is Leslie
age := 34
fmt.Printf("I am %d years old", age)
// I am 34 years old
fmt.Printf("%v is of type %T", name, name)
// Leslie is of type string