1
2
3
4
5 package bio
6
7 import (
8 "io"
9 "log"
10 )
11
12
13 func MustClose(c io.Closer) {
14 if err := c.Close(); err != nil {
15 log.Fatal(err)
16 }
17 }
18
19
20
21 func MustWriter(w io.Writer) io.Writer {
22 return mustWriter{w}
23 }
24
25 type mustWriter struct {
26 w io.Writer
27 }
28
29 func (w mustWriter) Write(b []byte) (int, error) {
30 n, err := w.w.Write(b)
31 if err != nil {
32 log.Fatal(err)
33 }
34 return n, nil
35 }
36
37 func (w mustWriter) WriteString(s string) (int, error) {
38 n, err := io.WriteString(w.w, s)
39 if err != nil {
40 log.Fatal(err)
41 }
42 return n, nil
43 }
44
View as plain text