]> Cypherpunks repositories - gostls13.git/commitdiff
go/doc: disable playground for examples that use syscall/js
authorRichard Musiol <mail@richard-musiol.de>
Sat, 10 Nov 2018 14:31:32 +0000 (15:31 +0100)
committerRichard Musiol <neelance@gmail.com>
Tue, 20 Nov 2018 20:56:13 +0000 (20:56 +0000)
The playground is not using GOOS=js, so it is not able to use the
package syscall/js. Examples that depend on syscall/js should not
show a "Run" button.

Fixes #28526.

Change-Id: I8b2fcdd0c0ee517a5c3864bf459f813129542389
Reviewed-on: https://go-review.googlesource.com/c/148918
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/go/doc/example.go

index cf3547810ad1bebd7863ffbff3a4814c1c047455..45350f8fd3532f5d15be8c6d4d7c38a4e9e2d1a7 100644 (file)
@@ -268,6 +268,11 @@ func playExample(file *ast.File, f *ast.FuncDecl) *ast.File {
                if err != nil {
                        continue
                }
+               if p == "syscall/js" {
+                       // We don't support examples that import syscall/js,
+                       // because the package syscall/js is not available in the playground.
+                       return nil
+               }
                n := path.Base(p)
                if s.Name != nil {
                        n = s.Name.Name