User Input (fmt.Scan, bufio, os.Args, strconv) - Go Tutorial for Beginners #5
13views
005:43
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Learn how to read user input in Go!
In this lesson, you will learn:
โ
Basic input with fmt.Scan and fmt.Scanln
โ
Reading full lines with bufio.Reader and bufio.Scanner
โ
Accessing command-line arguments with os.Args
โ
Parsing strings to numbers with strconv (Atoi, ParseFloat, ParseBool)
๐ Timestamps:
0:00 - Introduction
0:24 - Basic Input with fmt.Scan
1:20 - Line Input with bufio
2:17 - Command Line Arguments
3:11 - Parsing with strconv
4:17 - Recap
4:47 - End
๐ป Code from this lesson:
// Basic input with fmt.Scan
var name string
fmt.Print("Enter your name: ")
fmt.Scanln(&name)
// Reading lines with bufio
reader := bufio.NewReader(os.Stdin)
line, _ := reader.ReadString('\n')
// Command-line arguments
fmt.Println(os.Args[0]) // program name
fmt.Println(os.Args[1]) // first argument
๐ Previous: Lesson 4 - Numbers & Math
๐ Next: Lesson 6 - Control Flow: if/else
Back to tutorials๐ Read the articleOpen in YouTube
Duration
5:43
Published
January 27, 2026
Added to Codegiz
March 15, 2026