From 39d4178735d6ca90e076b3fc3d7e38f56fd6b945 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 30 Jul 2019 16:16:03 -0700 Subject: [PATCH] spec: add an example of a trivially invalid interface In preparation for the forthcoming spec changes for #6977. While at it, modernize existing File example that dates back all the way to commit 18c5b488a3b. Change-Id: Id10e4df0513e3de15bd58867222923eefa9473ea Reviewed-on: https://go-review.googlesource.com/c/go/+/187978 Reviewed-by: Rob Pike Reviewed-by: Matthew Dempsky Reviewed-by: Ian Lance Taylor --- doc/go_spec.html | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index fb4341be1d..89732fb8f2 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -1257,11 +1257,19 @@ non-blank name.

-// A simple File interface
+// A simple File interface.
 interface {
-	Read(b Buffer) bool
-	Write(b Buffer) bool
-	Close()
+	Read([]byte) (int, error)
+	Write([]byte) (int, error)
+	Close() error
+}
+
+ +
+interface {
+	String() string
+	String() string  // illegal: String not unique
+	_(x int)         // illegal: method must have non-blank name
 }
 
@@ -1272,9 +1280,9 @@ have the method set

-func (p T) Read(b Buffer) bool { return … }
-func (p T) Write(b Buffer) bool { return … }
-func (p T) Close() { … }
+func (p T) Read(p []byte) (n int, err error)   { return … }
+func (p T) Write(p []byte) (n int, err error)  { return … }
+func (p T) Close() error                       { return … }
 

-- 2.50.0