码迷,mamicode.com
首页 > 其他好文 > 详细

line filters _ golang

时间:2015-03-31 14:13:53      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

A line filter is a common type of program that reads input on stdin, processes it, and then prints some derived result to stdout. grep and sed are common line filters

package main

import (
    "bufio"
    "fmt"
    "os"
    "strings"
)

func main() {

    scanner := bufio.NewScanner(os.Stdin)

    for scanner.Scan() {
        ucl := strings.ToUpper(scanner.Text())
        fmt.Println(ucl)
    }

    if err := scanner.Err(); err != nil {
        fmt.Fprintln(os.Stderr, "error:", err)
        os.Exit(1)
    }
}
jsjsksksjk
JSJSKSKSJK
hshfhfj
HSHFHFJ
^Cexit status 2

总结  :

  1 : ......

line filters _ golang

标签:

原文地址:http://www.cnblogs.com/jackkiexu/p/4380594.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!