-
Notifications
You must be signed in to change notification settings - Fork 35
/
gen-tabledata.go
64 lines (59 loc) · 1.02 KB
/
gen-tabledata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright ©2017 The go-hep Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build ignore
// gen-tabledata generates tabledata.go
package main
import (
"io"
"log"
"os"
)
func main() {
f, err := os.Create("tabledata.go")
if err != nil {
log.Fatalf(
"could not create 'tabledata.go': %v\n",
err,
)
}
defer f.Close()
for _, fname := range []string{
"tabledata.header",
"tabledata.tbl",
"tabledata.footer",
} {
src, err := os.Open(fname)
if err != nil {
log.Fatalf(
"could not open data file [%s]: %v\n",
fname,
err,
)
}
defer src.Close()
_, err = io.Copy(f, src)
if err != nil {
log.Fatalf(
"error copying content of [%s]: %v\n",
fname,
err,
)
}
err = src.Close()
if err != nil {
log.Fatalf(
"error closing file [%s]: %v\n",
fname,
err,
)
}
}
err = f.Close()
if err != nil {
log.Fatalf("error closing [%s]: %v\n",
f.Name(),
err,
)
}
}