github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/tools/cmd/present/play_socket.go (about)

     1  // Copyright 2015 The Go Authors.  All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build !appengine,!appenginevm
     6  
     7  package main
     8  
     9  import (
    10  	"net/http"
    11  	"net/url"
    12  	"runtime"
    13  
    14  	"golang.org/x/tools/playground/socket"
    15  	"golang.org/x/tools/present"
    16  )
    17  
    18  func initPlayground(basepath string, origin *url.URL) {
    19  	if present.PlayEnabled {
    20  		if *nativeClient {
    21  			socket.RunScripts = false
    22  			socket.Environ = func() []string {
    23  				if runtime.GOARCH == "amd64" {
    24  					return environ("GOOS=nacl", "GOARCH=amd64p32")
    25  				}
    26  				return environ("GOOS=nacl")
    27  			}
    28  		}
    29  		playScript(basepath, "SocketTransport")
    30  		http.Handle("/socket", socket.NewHandler(origin))
    31  	}
    32  }
    33  
    34  func playable(c present.Code) bool {
    35  	return present.PlayEnabled && c.Play
    36  }