Concise Go Text Transformation

GoGoBeginner
Practice Now

This tutorial is from open-source community. Access the source code

Introduction

The Line Filters challenge is a common type of program that reads input on stdin, processes it, and then prints some derived result to stdout. The purpose of this challenge is to write a Go program that reads input text and modifies it according to specific requirements.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL go(("`Go`")) -.-> go/FileOperationsGroup(["`File Operations`"]) go/FileOperationsGroup -.-> go/line_filters("`Line Filters`") subgraph Lab Skills go/line_filters -.-> lab-15406{{"`Concise Go Text Transformation`"}} end

Line Filters

The problem to be solved in this challenge is to write a Go program that reads input text from stdin, capitalizes all the letters in the text, and then prints the modified text to stdout.

Requirements

  • The program must read input text from stdin.
  • The program must capitalize all the letters in the input text.
  • The program must print the modified text to stdout.

Example

## To try out our line filter, first make a file with a few
## lowercase lines.
$ echo 'hello' > /tmp/lines
$ echo 'filter' >> /tmp/lines

## Then use the line filter to get uppercase lines.
$ cat /tmp/lines | go run line-filters.go
HELLO
FILTER

Summary

The Line Filters challenge requires writing a Go program that reads input text from stdin, capitalizes all the letters in the text, and then prints the modified text to stdout. This challenge is a great way to practice writing Go programs that read and modify input text.

Other Go Tutorials you may like