go-hep.org/x/hep@v0.38.1/sio/cmd/sio-ls-records/main.go (about) 1 // Copyright ©2017 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main // import "go-hep.org/x/hep/sio/cmd/sio-ls-records" 6 7 import ( 8 "flag" 9 "fmt" 10 "os" 11 12 "go-hep.org/x/hep/sio" 13 ) 14 15 func main() { 16 var fname string 17 18 flag.Parse() 19 20 if flag.NArg() > 0 { 21 fname = flag.Arg(0) 22 } 23 24 fmt.Printf("::: inspecting file [%s]...\n", fname) 25 if fname == "" { 26 flag.Usage() 27 os.Exit(1) 28 } 29 30 f, err := sio.Open(fname) 31 if err != nil { 32 fmt.Printf("*** error: %v\n", err) 33 os.Exit(1) 34 } 35 defer f.Close() 36 37 _, _ = f.ReadRecord() 38 39 _, err = f.Seek(0, 0) 40 if err != nil { 41 fmt.Printf("*** error: %v\n", err) 42 } 43 44 for _, rec := range f.Records() { 45 fmt.Printf(" -> %v\n", rec.Name()) 46 } 47 48 fmt.Printf("::: inspecting file [%s]... [done]\n", fname) 49 }