func TestPackDir(t *testing.T) {
	var err error
	var pack wpk.Writer
	var fwpk *os.File
	var tagsnum = 0
	defer os.Remove(testpack)
	if fwpk, err = os.OpenFile(testpack, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
		t.Fatal(err)
	}
	defer fwpk.Close()
	if err = pack.Begin(fwpk); err != nil {
		t.Fatal(err)
	}
	if err = pack.PackDir(fwpk, mediadir, "", func(fi os.FileInfo, fname, fpath string) bool {
		if !fi.IsDir() {
			tagsnum++
			t.Logf("put file #%d '%s', %d bytes", pack.LastFID, fname, fi.Size())
		}
		return true
	}); err != nil {
		t.Fatal(err)
	}
	if err = pack.Finalize(fwpk); err != nil {
		t.Fatal(err)
	}
	CheckPackage(t, fwpk, tagsnum)
}
Test PackDir function work.
package wpk_test
import (
	"bytes"
	"os"
	"path/filepath"
	"testing"
	"github.com/schwarzlichtbezirk/wpk"
)
var mediadir = wpk.Envfmt("${GOPATH}/src/github.com/schwarzlichtbezirk/wpk/test/media/")
var testpack = filepath.Join(os.TempDir(), "testpack.wpk")
var memdata = map[string][]byte{
	"sample.txt": []byte("The quick brown fox jumps over the lazy dog"),
	"array.dat": {
		0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
		100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
		200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
	},
}
func CheckPackage(t *testing.T, fwpk *os.File, tagsnum int) {
	var err error
	var pack wpk.Writer
	if err = pack.Read(fwpk); err != nil {
		t.Fatal(err)
	}
	if len(pack.Tags) != tagsnum {
		t.Fatalf("expected %d entries in package, realy got %d entries", tagsnum, len(pack.Tags))
	}
	for _, tags := range pack.Tags {
		var _, isfile = tags[wpk.TIDcreated]
		var kpath = tags.Path()
		var link, is = tags[wpk.TIDlink]
		if isfile && !is {
			t.Fatalf("found file without link #%d '%s'", tags.FID(), kpath)
		}
		var offset, size = tags.Offset(), tags.Size()
		var orig []byte
		if isfile {
			if orig, err = os.ReadFile(mediadir + string(link)); err != nil {
				t.Fatal(err)
			}
		} else {
			var is bool
			if orig, is = memdata[kpath]; !is {
				t.Fatalf("memory block named as '%s' not found", kpath)
			}
		}
		if size != int64(len(orig)) {
			t.Errorf("size of file '%s' (%d) in package is defer from original (%d)",
				kpath, size, len(orig))
		}
		var extr = make([]byte, size, size)
		var n int
		if n, err = fwpk.ReadAt(extr, offset); err != nil {
			t.Fatal(err)
		}
		if n != len(extr) {
			t.Errorf("can not extract content of file '%s' completely", kpath)
		}
		if !bytes.Equal(orig, extr) {
			t.Errorf("content of file '%s' is defer from original", kpath)
		}
		if t.Failed() {
			break
		}
		if isfile {
			t.Logf("check file #%d '%s' is ok", tags.FID(), kpath)
		} else {
			t.Logf("check data #%d '%s' is ok", tags.FID(), kpath)
		}
	}
}