]> Cypherpunks.ru repositories - gorecfile.git/blob - cmd/gorecsel/main.go
Initial commit
[gorecfile.git] / cmd / gorecsel / main.go
1 package main
2
3 import (
4         "fmt"
5         "io"
6         "os"
7
8         "go.cypherpunks.ru/recfile"
9 )
10
11 func main() {
12         r := recfile.NewReader(os.Stdin)
13         n := 0
14         for {
15                 fields, err := r.Next()
16                 if err != nil {
17                         if err == io.EOF {
18                                 return
19                         }
20                         panic(err)
21                 }
22                 if n > 0 {
23                         fmt.Println("")
24                 }
25                 fmt.Println("Record:", n)
26                 for _, field := range fields {
27                         fmt.Printf("%s: %s\n", field.Name, field.Value)
28                 }
29                 n++
30         }
31 }