Skip to content

Commit

Permalink
go/doc: disable playground for examples that use syscall/js
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
neelance authored and Richard Musiol committed Nov 20, 2018
1 parent 7c71aa2 commit 339e5ff
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/go/doc/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 339e5ff

Please sign in to comment.