Add ExtractAll func to meta pkg

Issue #46 resolved
Saxon Milton created an issue

I propose that we add a ExtractAll func to the meta pkg. This will allow us to extract all meta from a psi as a [][]string.

Comments (11)

  1. Saxon Milton reporter

    The current function to extract a particular value for a given key is called Extract - Dan suggested this, as any function with Read in the name implies a reader is involved - so it seems natural to have this ExtractAll. @kortschak thoughts ?

  2. kortschak

    The most commonly used method name for this (see "reflect", "os" and others) is Get*(string) string where the zero string is an absent k/v pair, but Get(string) (val string, ok boo) seems pretty reasonable. For the complete set, GetAll() map[string]string?

  3. Saxon Milton reporter

    @kortschak to clarify this was getting the metadata from a descriptor, so current signature for Extract is meta.Extract(key string, descriptorData []byte). I would like to do meta.ExtractAll(descriptorData []byte) [][2]string.

  4. kortschak

    Hmm. I'm not sure now. Leave it as is and we can change it later. The normal API would be to parse and then extract (like with url.URL), but that seems to heavy here.

  5. Alan Noble

    Extract” suggests that something substantial is actually happening, as in extract from a zip/archive. That is not the case here. “Get” really is the best verb in this case. Also, almost every dictionary/map in every language uses "Get".

  6. Log in to comment