@@ -14,6 +14,7 @@ import (
14
14
"github.com/x1unix/go-playground/pkg/analyzer"
15
15
"github.com/x1unix/go-playground/pkg/compiler"
16
16
"github.com/x1unix/go-playground/pkg/compiler/storage"
17
+ "github.com/x1unix/go-playground/pkg/goplay"
17
18
"github.com/x1unix/go-playground/pkg/langserver"
18
19
"go.uber.org/zap"
19
20
)
@@ -23,6 +24,7 @@ var Version = "testing"
23
24
24
25
type appArgs struct {
25
26
packagesFile string
27
+ playgroundUrl string
26
28
addr string
27
29
debug bool
28
30
buildDir string
@@ -39,6 +41,7 @@ func main() {
39
41
flag .StringVar (& args .addr , "addr" , ":8080" , "TCP Listen address" )
40
42
flag .StringVar (& args .buildDir , "wasm-build-dir" , os .TempDir (), "Directory for WASM builds" )
41
43
flag .StringVar (& args .cleanupInterval , "clean-interval" , "10m" , "Build directory cleanup interval" )
44
+ flag .StringVar (& args .playgroundUrl , "playground-url" , goplay .DefaultPlaygroundURL , "Go Playground URL" )
42
45
flag .BoolVar (& args .debug , "debug" , false , "Enable debug mode" )
43
46
44
47
goRoot , ok := os .LookupEnv ("GOROOT" )
@@ -80,6 +83,7 @@ func start(goRoot string, args appArgs) error {
80
83
81
84
zap .S ().Info ("Server version: " , Version )
82
85
zap .S ().Infof ("GOROOT is %q" , goRoot )
86
+ zap .S ().Infof ("Playground url: %q" , args .playgroundUrl )
83
87
zap .S ().Infof ("Packages file is %q" , args .packagesFile )
84
88
zap .S ().Infof ("Cleanup interval is %s" , cleanInterval .String ())
85
89
analyzer .SetRoot (goRoot )
@@ -98,7 +102,8 @@ func start(goRoot string, args appArgs) error {
98
102
go store .StartCleaner (ctx , cleanInterval , nil )
99
103
100
104
r := mux .NewRouter ()
101
- langserver .New (Version , packages , compiler .NewBuildService (zap .S (), store )).
105
+ pg := goplay .NewClient (args .playgroundUrl , goplay .DefaultUserAgent , 15 * time .Second )
106
+ langserver .New (Version , pg , packages , compiler .NewBuildService (zap .S (), store )).
102
107
Mount (r .PathPrefix ("/api" ).Subrouter ())
103
108
r .PathPrefix ("/" ).Handler (langserver .SpaFileServer ("./public" ))
104
109
0 commit comments