The definitions for indexed fmt verbs are incorrect; this is driven by the test cases being incorrect. The correct syntax for an indexed fmt verb has the argument indexing immediately before the verb. This is not what the definitions are tested against.
The syntax shown in the tests can be demonstrated to be incorrect by running the following program (or reading the fmt docs, but this is quicker). In the two examples, the syntax corresponding to the tests here gives incorrect output.
The tests should look like this (with other tests that should also pass added).
diff --git a/Go/tests/syntax_test_go.go b/Go/tests/syntax_test_go.go
index be5985f3..de540103 100644
--- a/Go/tests/syntax_test_go.go
+++ b/Go/tests/syntax_test_go.go
@@ -4490,6 +4490,9 @@ by accident, but if necessary, such support could be sacrificed.
// ^^ constant.other.placeholder.go
"one %+v two"
// ^^^^^^^^^^^^^ meta.string.go string.quoted.double.go
+// ^^^ constant.other.placeholder.go
+ "one %#v two"
+// ^^^^^^^^^^^^^ meta.string.go string.quoted.double.go
// ^^^ constant.other.placeholder.go
"one %1.2d two"
// ^^^^^^^^^^^^^^^ meta.string.go string.quoted.double.go
@@ -4500,10 +4503,13 @@ by accident, but if necessary, such support could be sacrificed.
"one %[1]v two"
// ^^^^^^^^^^^^^^^ meta.string.go string.quoted.double.go
// ^^^^^ constant.other.placeholder.go
- "one %[1]+v two"
+ "one %+[1]v two"
+// ^^^^^^^^^^^^^^^^ meta.string.go string.quoted.double.go
+// ^^^^^^ constant.other.placeholder.go
+ "one %#[1]v two"
// ^^^^^^^^^^^^^^^^ meta.string.go string.quoted.double.go
// ^^^^^^ constant.other.placeholder.go
- "one %[1]1.2d two"
+ "one %1.2[1]d two"
// ^^^^^^^^^^^^^^^^^^ meta.string.go string.quoted.double.go
// ^^^^^^^^ constant.other.placeholder.go
"foo %*f bar"
It's been at least a couple of years since I made a contribution here, and I have no recollection of where to get the testing tools from, and I don't see it in the README.
What happened?
The definitions for indexed fmt verbs are incorrect; this is driven by the test cases being incorrect. The correct syntax for an indexed fmt verb has the argument indexing immediately before the verb. This is not what the definitions are tested against.
For example, https://github.com/sublimehq/Packages/blob/bc9e712e859054d5d6d82d09755ef559dfe4455c/Go/tests/syntax_test_go.go#L4503 and https://github.com/sublimehq/Packages/blob/bc9e712e859054d5d6d82d09755ef559dfe4455c/Go/tests/syntax_test_go.go#L4506
The syntax shown in the tests can be demonstrated to be incorrect by running the following program (or reading the fmt docs, but this is quicker). In the two examples, the syntax corresponding to the tests here gives incorrect output.
https://go.dev/play/p/LIFcr4GbQZj output:
The tests should look like this (with other tests that should also pass added).
It's been at least a couple of years since I made a contribution here, and I have no recollection of where to get the testing tools from, and I don't see it in the README.