‘fmt.Scanln’
function is used to read data from user.
Syntax
fmt.Scanln(&variableName)
HelloWorld.go
package main import "fmt" func main() { var name string var id int fmt.Println("Enter your name") fmt.Scanln(&name) fmt.Println("Enter your id") fmt.Scanln(&id) fmt.Println("name : ", name, " id ", id) }
Output
Enter your
name
Krishna
Enter your
id
123
name
: Krishna id 123
No comments:
Post a Comment