]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modindex: update index_format.txt
authorBryan C. Mills <bcmills@google.com>
Thu, 27 Apr 2023 17:23:10 +0000 (13:23 -0400)
committerGopher Robot <gobot@golang.org>
Sat, 13 May 2023 00:22:50 +0000 (00:22 +0000)
This incorporates the changes from CL 453603 and CL 416178.

Please review carefully: I did my best to read through the CLs, but
I'm not entirely confident I haven't made a mistake.

Fixes #59770.

Change-Id: Ib8937e55dcd11e3f75c16b28519d3d91df1d4da3
Reviewed-on: https://go-review.googlesource.com/c/go/+/492596
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/cmd/go/internal/modindex/index_format.txt
src/cmd/go/internal/modindex/read.go

index a593391f7e073d817497f0816253bb2612fbde62..8b1d2c6bc5b871d4828fca2aac31bda460ae8f26 100644 (file)
@@ -3,18 +3,19 @@ The index format is an encoding of a series of RawPackage structs
 
 Field names refer to fields on RawPackage and rawFile.
 The file uses little endian encoding for the uint32s.
-Strings are written into the string table at the end of the file. Each string
-is null-terminated. String offsets are relative to the start of the string table.
+Strings are written into the string table at the end of the file.
+Each string is prefixed with a uvarint-encoded length.
 Bools are written as uint32s: 0 for false and 1 for true.
 
 The following is the format for a full module:
 
-“go index v0\n”
+“go index v2\n”
 str uint32 - offset of string table
 n uint32 - number of packages
-dirnames [n]uint32 - offsets to package names in string table; names sorted by raw string
-packages [n]uint32 - offset where package begins
-for each RawPackage:
+for each rawPackage:
+       dirname - string offset
+       package - offset where package begins
+for each rawPackage:
        error uint32 - string offset // error is produced by fsys.ReadDir or fmt.Errorf
        dir uint32 - string offset (directory path relative to module root)
        len(sourceFiles) uint32
@@ -35,11 +36,16 @@ for each RawPackage:
                for each rawImport:
                        path - string offset
                        position - file, offset, line, column - uint32
-               len(embeds) numEmbeds uint32
+               len(embeds) uint32
                for each embed:
                        pattern - string offset
                        position - file, offset, line, column - uint32
+               len(directives) uint32
+               for each directive:
+                       text - string offset
+                       position - file, offset, line, column - uint32
 [string table]
+0xFF (marker)
 
 The following is the format for a single indexed package:
 
index 1fa250ad47c5d9442c74c228feefdacbeebf70e2..2ad5301d9e1a2dd65f9c192237dafdd0ecb7698b 100644 (file)
@@ -913,7 +913,7 @@ func (sf *sourceFile) embedsOffset() int {
 func (sf *sourceFile) directivesOffset() int {
        pos := sf.embedsOffset()
        n := sf.d.intAt(pos)
-       // each import is 5 uint32s (string + tokpos)
+       // each embed is 5 uint32s (string + tokpos)
        return pos + 4 + n*(4*5)
 }