fmt.Scanln() Function in Golang With Examples Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Scanln() function in Go language scans the input texts which is given in the standard input, reads from there and stores the successive space-separated values into successive arguments. This function stops scanning at a newline and after the final item, there must be a newline or EOF. Moreover, this function is defined under the fmt package. Here, you need to import the "fmt" package in order to use these functions. Syntax: func Scanln(a ...interface{}) (n int, err error) Here, "a ...interface{}" receives each given texts. Returns: It returns the number of items successfully scanned. Example 1: C // Golang program to illustrate the usage of // fmt.Scanln() function // Including the main package package main // Importing fmt import ( "fmt" ) // Calling main func main() { // Declaring some variables var name string var alphabet_count int // Calling Scanln() function for // scanning and reading the input // texts given in standard input fmt.Scanln(&name) fmt.Scanln(&alphabet_count) // Printing the given texts fmt.Printf("%s %d", name, alphabet_count) } Input: GFG 3 Output: GFG 0 Example 2: C // Golang program to illustrate the usage of // fmt.Scanln() function // Including the main package package main // Importing fmt import ( "fmt" ) // Calling main func main() { // Declaring some variables var name string var alphabet_count int // Calling Scanln() function for // scanning and reading the input // texts given in standard input fmt.Scanln(&name) fmt.Scanln(&alphabet_count) // Printing the given texts fmt.Printf("%s %d", name, alphabet_count) } Input: GeeksforGeeks \n 13 Output: GeeksforGeeks 0 In the above example, it can be seen that standard input takes the value of "GeeksforGeeks \n 13" but it returns output as "GeeksforGeeks 0" this is because of this function stop scanning at new line (\n). Comment More infoAdvertise with us Next Article fmt.Scanln() Function in Golang With Examples K Kanchan_Ray Follow Improve Article Tags : Go Language Golang-fmt Similar Reads fmt.Sscanln() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Sscanln() function in Go language scans the specified string and stores the successive space-separated values into successive arguments. This function stops scanning at a newli 2 min read fmt.Scan() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Scan() function in Go language scans the input texts which is given in the standard input, reads from there and stores the successive space-separated values into successive arg 2 min read fmt.Scanf() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Scanf() function in Go language scans the input texts which is given in the standard input, reads from there and stores the successive space-separated values into successive ar 2 min read fmt.Sscan() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Sscan() function in Go language scans the specified texts and store the successive space-separated texts into successive arguments. Moreover, this function is defined under the 2 min read fmt.Sscanf() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Sscanf() function in Go language scans the specified string and stores the successive space-separated values into successive arguments as determined by the format. Moreover, th 2 min read Like