diff --git a/doc/go_spec.html b/doc/go_spec.html index c62a168b1f6..486813878bf 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1674,6 +1674,20 @@ variables will be assigned the corresponding values. r, w := os.Pipe(fd); // os.Pipe() returns two values +

+A short variable declaration may redeclare variables provided they +were originally declared in the same block with the same type, and at +least one of the variables is new. As a consequence, redeclaration +can only appear in a multi-variable short declaration. +Redeclaration does not introduce a new +variable; it just assigns a new value to the original. +

+ +
+field1, offset := nextField(str, 0);
+field2, offset := nextField(str, offset);  // redeclares offset
+
+

Short variable declarations may appear only inside functions. In some contexts such as the initializers for if,