Exemple #1
0
func main() {
	rx := regexp.MustCompile(os.Args[1])

	r := mllp.NewReader(os.Stdin)
	w := mllp.NewWriter(os.Stdout)

	i := 0
	for {
		m, err := r.ReadMessage()
		if err != nil {
			if stackerr.HasUnderlying(err, stackerr.Equals(io.EOF)) {
				break
			}

			panic(err)
		}

		if rx.Match(m) {
			if err := w.WriteMessage(m); err != nil {
				panic(err)
			}
		}

		i++
	}
}
Exemple #2
0
func main() {
	r := mllp.NewReader(os.Stdin)

	i := 0
	for {
		if _, err := r.ReadMessage(); err != nil {
			if stackerr.HasUnderlying(err, stackerr.Equals(io.EOF)) {
				break
			}

			panic(err)
		}

		i++
	}

	fmt.Printf("total messages: %d\n", i)
}