diff options
author | Silvan Jegen <s.jegen@gmail.com> | 2016-01-19 17:18:57 +0100 |
---|---|---|
committer | Silvan Jegen <s.jegen@gmail.com> | 2016-01-19 17:18:57 +0100 |
commit | c4cd7d24d256e3f633fad02d5ca153ce881de2c5 (patch) | |
tree | 59d5d2fbe2c8d6c3c930d2a63e8171f93157cbf0 | |
parent | e3ca37535b8abf8fa7d1ab47c2b72f37dc0bea22 (diff) |
Read from stdin instead of a filestdin
-rw-r--r-- | htmlfilter.go | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/htmlfilter.go b/htmlfilter.go index 13b7fa4..0b00e51 100644 --- a/htmlfilter.go +++ b/htmlfilter.go @@ -11,21 +11,17 @@ import ( ) func main() { - var unxmlreader io.Reader - var n int + var ( + unxmlreader io.Reader + n int + err error + ) - f, err := os.Open(os.Args[1]) - if err != nil { - fmt.Fprintf(os.Stderr, "Error when opening file: %s\n", err) - } - - unxmlreader = unxml.NewReaderKeepTags(f, []string{"a"}) - //unxmlreader = unxml.NewReaderKeepTags(f, make([]string, 0)) + unxmlreader = unxml.NewReaderKeepTags(os.Stdin, make([]string, 0)) lineno := 0 - bbuffer := make([]byte, 100) + bbuffer := make([]byte, 4096) for { - n, err = unxmlreader.Read(bbuffer) if err != nil { if err == io.EOF || n == 0 { @@ -40,6 +36,4 @@ func main() { fmt.Printf("%s", bbuffer[:n]) } fmt.Printf("%s", bbuffer[:n]) - - f.Close() } |