Getting Input From Keyboard using Scanf | Go Lang Examples

#JavaInspires



 Hi Guys,

Welcome to Java Inspires..

In this post, we will see how to read or get input from keyboard using Scanf function from fmt pacakge.



sample.go

package main

import "fmt"

func main() {

	//Provide some question
	fmt.Println("What language you want to learn ?")
	// read answer using Scanf
	var answer string
	fmt.Scanf("%s", &answer)
	//print answer
	fmt.Println("Great... you are learning", answer, "language")
}


PS C:\Users\developer\Desktop> go run .\sample.go
What language you want to learn ?
Go...
Great... you are learning Go... language
PS C:\Users\developer\Desktop> 

THANK YOU


#JavaInspires

Post a Comment

Previous Post Next Post