22 lines
369 B
Go
22 lines
369 B
Go
|
package meta
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"encoding/json"
|
||
|
"io"
|
||
|
)
|
||
|
|
||
|
func ReadBytes(input io.ReadCloser) ([]byte, error) {
|
||
|
defer input.Close()
|
||
|
meta := &Meta{}
|
||
|
buf := &bytes.Buffer{}
|
||
|
if _, err := io.Copy(buf, input); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
bufBytes := buf.Bytes()
|
||
|
if err := json.Unmarshal(bufBytes, meta); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return bufBytes, nil
|
||
|
}
|