You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: export.go
    path of file: ./repos/faasd/vendor/github.com/Microsoft/hcsshim/pkg/ociwclayer
    
    the code of the file until where you have to start completion: //go:build windows

package ociwclayer

import (
	"archive/tar"
	"context"
	"io"
	"path/filepath"

	"github.com/Microsoft/go-winio/backuptar"
	"github.com/Microsoft/hcsshim/internal/wclayer"
)

    
func writeTarFromLayer(ctx context.Context, r wclayer.LayerReader, w io.Writer) error {
	linkRecords := make(map[[16]byte]string)

	t := tar.NewWriter(w)
	for {
		select {
		case <-ctx.Done():
			return ctx.Err()
		default:
		}

		name, size, fileInfo, err := r.Next()
		if err == io.EOF {
			break
		}
		if err != nil {
			return err
		}
		if fileInfo == nil {
			// Write a whiteout file.
			hdr := &tar.Header{
				Name: filepath.ToSlash(filepath.Join(filepath.Dir(name), whiteoutPrefix+filepath.Base(name))),
			}
			err := t.WriteHeader(hdr)
			if err != nil {
				return err
			}
		} else {
			numberOfLinks, fileIDInfo, err := r.LinkInfo()
			if err != nil {
				return err
			}
			if numberOfLinks > 1 {
				if linkName, ok := linkRecords[fileIDInfo.FileID]; ok {
					// We've seen this file before, by another name, so put a hardlink in the tar stream.
					hdr := backuptar.BasicInfoHeader(name, 0, fileInfo)
					hdr.Mode = 0644
					hdr.Typeflag = tar.TypeLink
					hdr.Linkname = linkName
					if err := t.WriteHeader(hdr); err != nil {
						return err
					}
					continue
				}

				// All subsequent names for this file will be hard-linked to this name
				linkRecords[fileIDInfo.FileID] = filepath.ToSlash(name)
			}

			err = backuptar.WriteTarFileFromBackupStream(t, r, name, size, fileInfo)
			if err != nil {
				return err
			}
		}
	}
	return t.Close()
}