mirror of https://bitbucket.org/ausocean/av.git
stream/mts/meta/meta.go: Extract and ExtractAll to Get and GetAll
This commit is contained in:
parent
fadc1fed1b
commit
f9d8accdae
|
@ -168,7 +168,7 @@ func (m *Data) Encode() []byte {
|
|||
// ReadFrom extracts a value from a metadata string d, for the given key. If the
|
||||
// key is not present in the metadata string, an error is returned. If the
|
||||
// metadata header is not present in the string, an error is returned.
|
||||
func Extract(key string, d []byte) (string, error) {
|
||||
func Get(key string, d []byte) (string, error) {
|
||||
err := checkHeader(d)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -186,7 +186,7 @@ func Extract(key string, d []byte) (string, error) {
|
|||
|
||||
// ExtractAll extracts all metadata entries from given data. An Error is returned
|
||||
// if the metadata does not have a valid header, or if the meta format is unexpected.
|
||||
func ExtractAll(d []byte) ([][2]string, error) {
|
||||
func GetAll(d []byte) ([][2]string, error) {
|
||||
err := checkHeader(d)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -156,7 +156,7 @@ func TestReadFrom(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
got, err := Extract(test.key, []byte(tstMeta))
|
||||
got, err := Get(test.key, []byte(tstMeta))
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected err: %v\n", err)
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ func TestExtractAll(t *testing.T) {
|
|||
"12345",
|
||||
},
|
||||
}
|
||||
got, err := ExtractAll(tstMeta)
|
||||
got, err := GetAll(tstMeta)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v\n", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue