| 1 | package fsutilscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/ |
| 2 | |
| 3 | import ( |
| 4 | "contextscip-go gomod github.com/golang/go/src go1.21 context/" |
| 5 | gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/ "io/fsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/" |
| 6 | "osscip-go gomod github.com/golang/go/src go1.21 os/" |
| 7 | "path/filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/" |
| 8 | "runtimescip-go gomod github.com/golang/go/src go1.21 runtime/" |
| 9 | "sortscip-go gomod github.com/golang/go/src go1.21 sort/" |
| 10 | stringsscip-go gomod github.com/golang/go/src go1.21 strings/ "stringsscip-go gomod github.com/golang/go/src go1.21 strings/" |
| 11 | "syscallscip-go gomod github.com/golang/go/src go1.21 syscall/" |
| 12 | |
| 13 | "github.com/pkg/errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/" |
| 14 | "github.com/tonistiigi/fsutil/typesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/" |
| 15 | ) |
| 16 | |
| 17 | func FollowLinksscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FollowLinks().(fs FSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS#, paths []string) ([]string, error) { |
| 18 | r := &symlinkResolverscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#{fsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#fs.: fs, resolvedscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#resolved.: map[string]struct{}{}} |
| 19 | for _, p := range paths { |
| 20 | if err := r.appendscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#append().(p); err != nil { |
| 21 | return nil, err |
| 22 | } |
| 23 | } |
| 24 | res := make([]string, 0, len(r.resolvedscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#resolved.)) |
| 25 | for r := range r.resolvedscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#resolved. { |
| 26 | res = append(res, filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.ToSlashscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/ToSlash().(r)) |
| 27 | } |
| 28 | sortscip-go gomod github.com/golang/go/src go1.21 sort/.Stringsscip-go gomod github.com/golang/go/src go1.21 sort/Strings().(res) |
| 29 | return dedupePathsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/dedupePaths().(res), nil |
| 30 | } |
| 31 | |
| 32 | type symlinkResolverscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver# struct { |
| 33 | fsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#fs. FSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS# |
| 34 | resolvedscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#resolved. map[string]struct{} |
| 35 | } |
| 36 | |
| 37 | func (r *symlinkResolverscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#) appendscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#append().(p string) error { |
| 38 | if runtimescip-go gomod github.com/golang/go/src go1.21 runtime/.GOOSscip-go gomod github.com/golang/go/src go1.21 runtime/GOOS. == "windows" && filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.IsAbsscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/IsAbs().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.FromSlashscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/FromSlash().(p)) { |
| 39 | absParts := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.SplitNscip-go gomod github.com/golang/go/src go1.21 strings/SplitN().(p, ":", 2) |
| 40 | if len(absParts) == 2 { |
| 41 | p = absParts[1] |
| 42 | } |
| 43 | } |
| 44 | p = filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(".", p) |
| 45 | current := "." |
| 46 | for { |
| 47 | parts := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.SplitNscip-go gomod github.com/golang/go/src go1.21 strings/SplitN().(p, string(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Separator.), 2) |
| 48 | current = filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(current, parts[0]) |
| 49 | |
| 50 | targets, err := r.readSymlinkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#readSymlink().(current, true) |
| 51 | if err != nil { |
| 52 | return err |
| 53 | } |
| 54 | p = "" |
| 55 | if len(parts) == 2 { |
| 56 | p = parts[1] |
| 57 | } |
| 58 | |
| 59 | if p == "" || targets != nil { |
| 60 | if _, ok := r.resolvedscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#resolved.[current]; ok { |
| 61 | return nil |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | if targets != nil { |
| 66 | r.resolvedscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#resolved.[current] = struct{}{} |
| 67 | for _, target := range targets { |
| 68 | if err := r.appendscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#append().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(target, p)); err != nil { |
| 69 | return err |
| 70 | } |
| 71 | } |
| 72 | return nil |
| 73 | } |
| 74 | |
| 75 | if p == "" { |
| 76 | r.resolvedscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#resolved.[current] = struct{}{} |
| 77 | return nil |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | func (r *symlinkResolverscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#) readSymlinkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#readSymlink().(p string, allowWildcard bool) ([]string, error) { |
| 83 | base := filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Base().(p) |
| 84 | if allowWildcard && containsWildcardsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/containsWildcards().(base) { |
| 85 | fis, err := readDirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/readDir().(r.fsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#fs., filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Dir().(p)) |
| 86 | if err != nil { |
| 87 | if isNotFoundscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/isNotFound().(err) { |
| 88 | return nil, nil |
| 89 | } |
| 90 | return nil, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.Wrapscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/Wrap().(err, "readdir") |
| 91 | } |
| 92 | var out []string |
| 93 | for _, f := range fis { |
| 94 | if ok, _ := filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Matchscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Match().(base, f.Namescip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#Name().()); ok { |
| 95 | res, err := r.readSymlinkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#readSymlink().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Dir().(p), f.Namescip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#Name().()), false) |
| 96 | if err != nil { |
| 97 | return nil, err |
| 98 | } |
| 99 | out = append(out, res...) |
| 100 | } |
| 101 | } |
| 102 | return out, nil |
| 103 | } |
| 104 | |
| 105 | entry, err := statFilescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/statFile().(r.fsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/symlinkResolver#fs., p) |
| 106 | if err != nil { |
| 107 | if isNotFoundscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/isNotFound().(err) { |
| 108 | return nil, nil |
| 109 | } |
| 110 | return nil, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(err) |
| 111 | } |
| 112 | if entry == nil { |
| 113 | return nil, nil |
| 114 | } |
| 115 | if entry.Typescip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#Type().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeSymlinkscip-go gomod github.com/golang/go/src go1.21 os/ModeSymlink. == 0 { |
| 116 | return nil, nil |
| 117 | } |
| 118 | |
| 119 | fi, err := entry.Infoscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#Info().() |
| 120 | if err != nil { |
| 121 | return nil, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(err) |
| 122 | } |
| 123 | stat, ok := fi.Sysscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Sys().().(*typesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#) |
| 124 | if !ok { |
| 125 | return nil, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(&osscip-go gomod github.com/golang/go/src go1.21 os/.PathErrorscip-go gomod github.com/golang/go/src go1.21 os/PathError#{Pathscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Path.: p, Errscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Err.: syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.EBADMSGscip-go gomod github.com/golang/go/src go1.21 syscall/EBADMSG., Opscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Op.: "fileinfo without stat info"}) |
| 126 | } |
| 127 | |
| 128 | link := filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Cleanscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Clean().(stat.Linknamescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Linkname.) |
| 129 | if filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.IsAbsscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/IsAbs().(link) { |
| 130 | return []string{link}, nil |
| 131 | } |
| 132 | return []string{ |
| 133 | filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(string(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Separator.), filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Dir().(p), link)), |
| 134 | }, nil |
| 135 | } |
| 136 | |
| 137 | func statFilescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/statFile().(fs FSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS#, root string) (osscip-go gomod github.com/golang/go/src go1.21 os/.DirEntryscip-go gomod github.com/golang/go/src go1.21 os/DirEntry#, error) { |
| 138 | var out osscip-go gomod github.com/golang/go/src go1.21 os/.DirEntryscip-go gomod github.com/golang/go/src go1.21 os/DirEntry# |
| 139 | |
| 140 | root = filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.FromSlashscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/FromSlash().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Cleanscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Clean().(root)) |
| 141 | if root == string(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Separator.) || root == "." { |
| 142 | return nil, nil |
| 143 | } |
| 144 | |
| 145 | err := fs.Walkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS#Walk.(contextscip-go gomod github.com/golang/go/src go1.21 context/.TODOscip-go gomod github.com/golang/go/src go1.21 context/TODO().(), root, func(p string, entry osscip-go gomod github.com/golang/go/src go1.21 os/.DirEntryscip-go gomod github.com/golang/go/src go1.21 os/DirEntry#, err error) error { |
| 146 | if err != nil { |
| 147 | return err |
| 148 | } |
| 149 | if p != root { |
| 150 | return errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.Errorfscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/Errorf().("expected single entry %q but got %q", root, p) |
| 151 | } |
| 152 | out = entry |
| 153 | if entry.IsDirscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#IsDir().() { |
| 154 | return filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.SkipDirscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/SkipDir. |
| 155 | } |
| 156 | return nil |
| 157 | }) |
| 158 | if err != nil { |
| 159 | return nil, err |
| 160 | } |
| 161 | |
| 162 | if out == nil { |
| 163 | return nil, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.Wrapfscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/Wrapf().(osscip-go gomod github.com/golang/go/src go1.21 os/.ErrNotExistscip-go gomod github.com/golang/go/src go1.21 os/ErrNotExist., "readFile %s", root) |
| 164 | } |
| 165 | return out, nil |
| 166 | } |
| 167 | |
| 168 | func readDirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/readDir().(fs FSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS#, root string) ([]osscip-go gomod github.com/golang/go/src go1.21 os/.DirEntryscip-go gomod github.com/golang/go/src go1.21 os/DirEntry#, error) { |
| 169 | var out []osscip-go gomod github.com/golang/go/src go1.21 os/.DirEntryscip-go gomod github.com/golang/go/src go1.21 os/DirEntry# |
| 170 | |
| 171 | root = filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.FromSlashscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/FromSlash().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Cleanscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Clean().(root)) |
| 172 | if root == string(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Separator.) || root == "." { |
| 173 | root = "." |
| 174 | out = make([]gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.DirEntryscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#, 0) |
| 175 | } |
| 176 | |
| 177 | err := fs.Walkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS#Walk.(contextscip-go gomod github.com/golang/go/src go1.21 context/.TODOscip-go gomod github.com/golang/go/src go1.21 context/TODO().(), root, func(p string, entry osscip-go gomod github.com/golang/go/src go1.21 os/.DirEntryscip-go gomod github.com/golang/go/src go1.21 os/DirEntry#, err error) error { |
| 178 | if err != nil { |
| 179 | return err |
| 180 | } |
| 181 | if p == root { |
| 182 | if !entry.IsDirscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#IsDir().() { |
| 183 | return errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(&osscip-go gomod github.com/golang/go/src go1.21 os/.PathErrorscip-go gomod github.com/golang/go/src go1.21 os/PathError#{Opscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Op.: "walk", Pathscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Path.: root, Errscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Err.: syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.ENOTDIRscip-go gomod github.com/golang/go/src go1.21 syscall/ENOTDIR.}) |
| 184 | } |
| 185 | out = make([]gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.DirEntryscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#, 0) |
| 186 | return nil |
| 187 | } |
| 188 | if out == nil { |
| 189 | return errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.Errorfscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/Errorf().("expected to read parent entry %q before child %q", root, p) |
| 190 | } |
| 191 | out = append(out, entry) |
| 192 | if entry.IsDirscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#IsDir().() { |
| 193 | return filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.SkipDirscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/SkipDir. |
| 194 | } |
| 195 | return nil |
| 196 | }) |
| 197 | if err != nil { |
| 198 | return nil, err |
| 199 | } |
| 200 | |
| 201 | if out == nil && root != "." { |
| 202 | return nil, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.Wrapfscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/Wrapf().(osscip-go gomod github.com/golang/go/src go1.21 os/.ErrNotExistscip-go gomod github.com/golang/go/src go1.21 os/ErrNotExist., "readDir %s", root) |
| 203 | } |
| 204 | return out, nil |
| 205 | } |
| 206 | |
| 207 | func containsWildcardsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/containsWildcards().(name string) bool { |
| 208 | isWindows := runtimescip-go gomod github.com/golang/go/src go1.21 runtime/.GOOSscip-go gomod github.com/golang/go/src go1.21 runtime/GOOS. == "windows" |
| 209 | for i := 0; i < len(name); i++ { |
| 210 | ch := name[i] |
| 211 | if ch == '\\' && !isWindows { |
| 212 | i++ |
| 213 | } else if ch == '*' || ch == '?' || ch == '[' { |
| 214 | return true |
| 215 | } |
| 216 | } |
| 217 | return false |
| 218 | } |
| 219 | |
| 220 | // dedupePaths expects input as a sorted list |
| 221 | func dedupePathsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/dedupePaths().(in []string) []string { |
| 222 | out := make([]string, 0, len(in)) |
| 223 | var last string |
| 224 | for _, s := range in { |
| 225 | // if one of the paths is root there is no filter |
| 226 | if s == "." { |
| 227 | return nil |
| 228 | } |
| 229 | if stringsscip-go gomod github.com/golang/go/src go1.21 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.21 strings/HasPrefix().(s, last+"/") { |
| 230 | continue |
| 231 | } |
| 232 | out = append(out, s) |
| 233 | last = s |
| 234 | } |
| 235 | return out |
| 236 | } |