MCPcopy Index your code
hub / github.com/gonum/plot / untargz

Function untargz

vg/example_test.go:85–113  ·  view source on GitHub ↗
(name string, r io.Reader)

Source from the content-addressed store, hash-verified

83}
84
85func untargz(name string, r io.Reader) ([]byte, error) {
86 gr, err := gzip.NewReader(r)
87 if err != nil {
88 return nil, fmt.Errorf("could not create gzip reader: %v", err)
89 }
90 defer gr.Close()
91
92 tr := tar.NewReader(gr)
93 for {
94 hdr, err := tr.Next()
95 if err != nil {
96 if err == io.EOF {
97 return nil, fmt.Errorf("could not find %q in tar archive", name)
98 }
99 return nil, fmt.Errorf("could not extract header from tar archive: %v", err)
100 }
101
102 if hdr == nil || hdr.Name != name {
103 continue
104 }
105
106 buf := new(bytes.Buffer)
107 _, err = io.Copy(buf, tr)
108 if err != nil {
109 return nil, fmt.Errorf("could not extract %q file from tar archive: %v", name, err)
110 }
111 return buf.Bytes(), nil
112 }
113}
114
115func Example_inMemoryCanvas() {
116 p := plot.New()

Callers 1

Example_addFontFunction · 0.85

Calls 1

CloseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…