mmadfox / go-crx3

Chrome browser extension tools. Provides a set of tools packing, unpacking, zip, unzip, download, etc.
Apache License 2.0
27 stars 8 forks source link

Support for buffered pack #7

Closed leetrout closed 2 months ago

leetrout commented 2 months ago

@mmadfox Would you be open to a PR to add support for packing in memory instead of the filesystem?

I'd like to have something like:

var b bytes.Buffer
if err := crx3.Extension("/path/to/extension").PackToBuf(b); err != nil {
    panic(err)
}
b.WriteTo(someHTTPResponseWriter)
mmadfox commented 2 months ago

Yes, this is a very good suggestion.

It seems to me this is more idiomatic WriteTo(io.Writer) than passing a Buffer. What do you think?

var b bytes.Buffer
if err := crx3.Extension("/path/to/extension").WriteTo(b); err != nil {
    panic(err)
}
b.WriteTo(someHTTPResponseWriter)
mmadfox commented 2 months ago

Added API for packing into a buffer. See the example

leetrout commented 2 months ago

Oh thank you very much!