diff options
| author | 2021-12-12 15:47:51 +0100 | |
|---|---|---|
| committer | 2021-12-12 15:47:51 +0100 | |
| commit | 67ac8db190eb82a7758746fb021fa3014f4241b7 (patch) | |
| tree | 4a4124ad8f0ee9ec8858b109dd0bcc2e567fc144 /vendor/golang.org/x/tools/go/gcexportdata | |
| parent | upstep dependencies (#339) (diff) | |
| download | gotosocial-67ac8db190eb82a7758746fb021fa3014f4241b7.tar.xz | |
Upstep Go dependencies (#340)
* Upstep Go dependencies
* tiny linter fix
* Tidy
Diffstat (limited to 'vendor/golang.org/x/tools/go/gcexportdata')
| -rw-r--r-- | vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go b/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go index fc8beea5d..cec819d64 100644 --- a/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go +++ b/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go @@ -50,11 +50,24 @@ func Find(importPath, srcDir string) (filename, path string) { // additional trailing data beyond the end of the export data. func NewReader(r io.Reader) (io.Reader, error) { buf := bufio.NewReader(r) - _, err := gcimporter.FindExportData(buf) - // If we ever switch to a zip-like archive format with the ToC - // at the end, we can return the correct portion of export data, - // but for now we must return the entire rest of the file. - return buf, err + _, size, err := gcimporter.FindExportData(buf) + if err != nil { + return nil, err + } + + if size >= 0 { + // We were given an archive and found the __.PKGDEF in it. + // This tells us the size of the export data, and we don't + // need to return the entire file. + return &io.LimitedReader{ + R: buf, + N: size, + }, nil + } else { + // We were given an object file. As such, we don't know how large + // the export data is and must return the entire file. + return buf, nil + } } // Read reads export data from in, decodes it, and returns type |
