From 7191ef7199cae4753dd7f06e66d9b82d760136aa Mon Sep 17 00:00:00 2001
From: Rob Pike
-TODO
+Before Go 1.1, a function that returned a value needed an explicit "return"
+or call to
+In Go 1.1, the rule about final "return" statements is more permissive.
+It introduces the concept of a
+terminating statement,
+a statement that is guaranteed to be the last one a function executes.
+Examples include
+"for" loops with no condition and "if-else"
+statements in which each half ends in a "return".
+If the final statement of a function can be shown syntactically to
+be a terminating statement, no final "return" statement is needed.
+
+Note that the rule is purely syntactic: it pays no attention to the values in the
+code and therefore requires no complex analysis.
+
+Updating: The change is backward-compatible, but existing code
+with superfluous "return" statements and calls to Return requirements
panic
at
+the end of the function; this was a simple way to make the programmer
+be explicit about the meaning of the function. But there are many cases
+where a final "return" is clearly unnecessary, such as a function with
+only an infinite "for" loop.
+panic
may
+be simplified manually.
+Such code can be identified by go vet
.
Changes to the implementations and tools
@@ -338,7 +367,7 @@ The reflect
package has several signifi
-It is now possible to run a select
statement using
+It is now possible to run a "select" statement using
the reflect
package; see the description of
Select
and
--
2.50.0