Line Filters
// Importing necessary packages.
import (
"bufio"
"fmt"
"os"
"strings"
)
// The main function, where the execution of the program begins.
func main() {
// Creating a new scanner to read input from standard input.
scanner := bufio.NewScanner(os.Stdin)
// Looping through each line of input.
for scanner.Scan() {
// Convert the text to uppercase.
ucl := strings.ToUpper(scanner.Text())
// Print the uppercase text.
fmt.Println(ucl)
}
// Checking for any errors that occurred during scanning.
if err := scanner.Err(); err != nil {
// Print the error message to standard error.
fmt.Fprintln(os.Stderr, "error:", err)
// Exit the program with a non-zero status code.
os.Exit(1)
}
}Output
Last updated