12// LicensesWrite writes the licenses to dst.
13func LicensesWrite(dst io.Writer) error {
14 copyFile := func(p string) error {
15 f, err := LicensesFsys.Open(p)
17 return fmt.Errorf("open license file: %v", err)
19 if _, err := io.Copy(dst, f); err != nil {
20 return fmt.Errorf("copy license file: %v", err)
22 if err := f.Close(); err != nil {
23 return fmt.Errorf("close license file: %v", err)
28 if _, err := fmt.Fprintf(dst, "# github.com/mjl-/mox/LICENSE\n\n"); err != nil {
31 if err := copyFile("LICENSE.MIT"); err != nil {
35 if _, err := fmt.Fprintf(dst, "\n\n# https://publicsuffix.org - Public Suffix List Mozilla\n\n"); err != nil {
38 if err := copyFile("LICENSE.MPLv2.0"); err != nil {
42 err := fs.WalkDir(LicensesFsys, "licenses", func(path string, d fs.DirEntry, err error) error {
43 if !d.Type().IsRegular() {
46 if _, err := fmt.Fprintf(dst, "\n\n# %s\n\n", strings.TrimPrefix(path, "licenses/")); err != nil {
52 return fmt.Errorf("walk licenses: %v", err)