summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-04-27 13:23:10 -0400
committerGopher Robot <gobot@golang.org>2023-05-13 00:22:50 +0000
commit91b8cc0dfaae12af1a89e2b7ad3da10728883ee1 (patch)
tree42a86b3f39acc71caba6fc6b6917382d7718ed20
parentdb22489012aabdd853d09d33e7525788d0acf2c4 (diff)
downloadgo-git-91b8cc0dfaae12af1a89e2b7ad3da10728883ee1.tar.gz
cmd/go/internal/modindex: update index_format.txt
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>
-rw-r--r--src/cmd/go/internal/modindex/index_format.txt20
-rw-r--r--src/cmd/go/internal/modindex/read.go2
2 files changed, 14 insertions, 8 deletions
diff --git a/src/cmd/go/internal/modindex/index_format.txt b/src/cmd/go/internal/modindex/index_format.txt
index a593391f7e..8b1d2c6bc5 100644
--- a/src/cmd/go/internal/modindex/index_format.txt
+++ b/src/cmd/go/internal/modindex/index_format.txt
@@ -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:
diff --git a/src/cmd/go/internal/modindex/read.go b/src/cmd/go/internal/modindex/read.go
index 1fa250ad47..2ad5301d9e 100644
--- a/src/cmd/go/internal/modindex/read.go
+++ b/src/cmd/go/internal/modindex/read.go
@@ -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)
}