Expose more of the package directly + simplify + better composability #26
Description
Many of the structs and their methods should progbly be exported directly and have exported members.. The way the package is constructed makes it nearly impossible to use in many situations.
There is also a needless involvment with details which the API consumer can take care of like the splitting of maintainer into separate name + email..
the exprted addFile.. methods should have a varant which takes something like io.reader + os.fileinfo so that it's possible to stream data into the archive.. The same problem exists in the other direction for DebPkg.Write()..
To me it's unexpected that a New() function allocates file descriptors. Maybe Open() is a better name to signal what actually is going on.
This is a lot more natual and easier to work with:
d := debpkg.Deb{
Name: c.Name,
Version: "1.2.3",
}
w, _ := d.Open(target)
// not exactly sure about the signature of WriteXXX. but probably one of these:
w.Data.WriteFile(name string, r io.Reader, size int64)
w.Control.WriteFile(name string, r io.Reader, os.FileInfo)
...
defer w.Close()
Than this:
d := debpkg.New()
defer d.Close()
d.SetName(c.Name)
d.SetVersion(c.Version)
...