stream/mts/meta/meta.go: Extract and ExtractAll to Get and GetAll

This commit is contained in:
saxon 2019-02-09 12:14:32 +10:30
parent fadc1fed1b
commit f9d8accdae
2 changed files with 4 additions and 4 deletions

View File

@ -168,7 +168,7 @@ func (m *Data) Encode() []byte {
// ReadFrom extracts a value from a metadata string d, for the given key. If the // 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 // 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. // 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) err := checkHeader(d)
if err != nil { if err != nil {
return "", err 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 // 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. // 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) err := checkHeader(d)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -156,7 +156,7 @@ func TestReadFrom(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
got, err := Extract(test.key, []byte(tstMeta)) got, err := Get(test.key, []byte(tstMeta))
if err != nil { if err != nil {
t.Errorf("Unexpected err: %v\n", err) t.Errorf("Unexpected err: %v\n", err)
} }
@ -180,7 +180,7 @@ func TestExtractAll(t *testing.T) {
"12345", "12345",
}, },
} }
got, err := ExtractAll(tstMeta) got, err := GetAll(tstMeta)
if err != nil { if err != nil {
t.Errorf("Unexpected error: %v\n", err) t.Errorf("Unexpected error: %v\n", err)
} }