How to Take Input from the User in Golang? Last Updated : 10 May, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Scanln function can be used to take the input from the user in the Golang. Below is the example of taking input from the user: C // Golang program to show how // to take input from the user package main import "fmt" // main function func main() { // Println function is used to // display output in the next line fmt.Println("Enter Your First Name: ") // var then variable name then variable type var first string // Taking input from user fmt.Scanln(&first) fmt.Println("Enter Second Last Name: ") var second string fmt.Scanln(&second) // Print function is used to // display output in the same line fmt.Print("Your Full Name is: ") // Addition of two string fmt.Print(first + " " + second) } Now save this file and execute as shown in the below screenshot: Description About the Program: main Package: When we build reusable pieces of code, we will develop a package as a shared library. But when we develop an executable program, we will use the package "main" for making the package as an executable program. The package "main" tells the Golang compiler that the package should compile as an executable program instead of a shared library. The main function in the package "main" will be the entry point of our executable program. Remember when we build shared libraries, we will not have any main package and main function in the package. fmt.Println is the print function which is used to print the output in the next line. While fmt.Print is used to display output in the same line. Whatever needs to be printed has to be written in inverted commas " ". var first string is the declaration of the variable first which is of string type. To declare variables following syntax needs to be followed: var var_name data_type fmt.Scanln(&first) is used to take input from user in the next line. While fmt.Scan is used to take input from user in the same line. Ampersand is necessary to give the reference as to in which variable we have to store the variable. The Last line will simply add the two string of First Name and Last Name and will output the Full Name. Comment More infoAdvertise with us Next Article How to use strconv.QuoteRune() Function in Golang? P pcpiyush1106 Follow Improve Article Tags : Go Language Write From Home Golang-Program Similar Reads How to take Input from a User in Scala? This article focuses on discussing various approaches to taking input from a user in Scala. Table of Content Using scala.io.StdIn.readLine() MethodUsing java.util.ScannerUsing Command-line ArgumentUsing scala.io.StdIn.readLine() MethodBelow is the Scala program to take input from the user: Scala obj 1 min read How to use strconv.Quote() Function in Golang? Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a Quote() function which is used to find a double-quoted Go string literal representing str and the returned string uses Go escape sequences 2 min read How to Install Golang in Termux? Termux is a command-line terminal emulator app for android built using JAVA language. It is built by Fredrik Fornwall. It has a Linux environment built within it, and it doesn't require any rooting or separate setup to run the terminal emulator.Go is a modern programming language built by Google Eng 2 min read How to Create Your Own Package in Golang? Go language is a high-level programming language developed at Google Inc. A high-level language is in simple words, the programming language category created by humans for human understanding. Before we jump onto high terminologies as packages, modules, functions, etc. let's write the most basic pro 7 min read How to use strconv.QuoteRune() Function in Golang? Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a QuoteRune() function which is used to find a single-quoted Go string literal representing rune and the returned string uses Go escape seque 2 min read How to use strconv.QuoteToASCII() Function in Golang? Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a QuoteToASCII() function which is used to find a double-quoted Go string literal representing str and the returned string uses Go escape seq 2 min read Like