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: followlinks.go
    path of file: ./repos/moby/vendor/github.com/tonistiigi/fsutil
    
    the code of the file until where you have to start completion: package fsutil

import (
	"context"
	gofs "io/fs"
	"os"
	"path/filepath"
	"runtime"
	"sort"
	strings "strings"
	"syscall"

	"github.com/pkg/errors"
	"github.com/tonistiigi/fsutil/types"
)

func FollowLinks(fs FS, paths []string) ([]string, error) {
	r := &symlinkResolver{fs: fs, resolved: map[string]struct{}{}}
	for _, p := range paths {
		if err := r.append(p); err != nil {
			return nil, err
		}
	}
	res := make([]string, 0, len(r.resolved))
	for r := range r.resolved {
		res = append(res, filepath.ToSlash(r))
	}
	sort.Strings(res)
	return dedupePaths(res), nil
}

type symlinkResolver struct {
	fs       FS
	resolved map[string]struct{}
}

func (r *symlinkResolver) append(p string) error {
	if runtime.GOOS == "windows" && filepath.IsAbs(filepath.Fr
    
func (r *symlinkResolver) readSymlink(p string, allowWildcard bool) ([]string, error) {
	base := filepath.Base(p)
	if allowWildcard && containsWildcards(base) {
		fis, err := readDir(r.fs, filepath.Dir(p))
		if err != nil {
			if isNotFound(err) {
				return nil, nil
			}
			return nil, errors.Wrap(err, "readdir")
		}
		var out []string
		for _, f := range fis {
			if ok, _ := filepath.Match(base, f.Name()); ok {
				res, err := r.readSymlink(filepath.Join(filepath.Dir(p), f.Name()), false)
				if err != nil {
					return nil, err
				}
				out = append(out, res...)
			}
		}
		return out, nil
	}

	entry, err := statFile(r.fs, p)
	if err != nil {
		if isNotFound(err) {
			return nil, nil
		}
		return nil, errors.WithStack(err)
	}
	if entry == nil {
		return nil, nil
	}
	if entry.Type()&os.ModeSymlink == 0 {
		return nil, nil
	}

	fi, err := entry.Info()
	if err != nil {
		return nil, errors.WithStack(err)
	}
	stat, ok := fi.Sys().(*types.Stat)
	if !ok {
		return nil, errors.WithStack(&os.PathError{Path: p, Err: syscall.EBADMSG, Op: "fileinfo without stat info"})
	}

	link := filepath.Clean(stat.Linkname)
	if filepath.IsAbs(link) {
		return []string{link}, nil
	}
	return []string{
		filepath.Join(string(filepath.Separator), filepath.Join(filepath.Dir(p), link)),
	}, nil
}