@@ -14,6 +14,7 @@ import (
1414	"github.com/x1unix/go-playground/pkg/analyzer" 
1515	"github.com/x1unix/go-playground/pkg/compiler" 
1616	"github.com/x1unix/go-playground/pkg/compiler/storage" 
17+ 	"github.com/x1unix/go-playground/pkg/goplay" 
1718	"github.com/x1unix/go-playground/pkg/langserver" 
1819	"go.uber.org/zap" 
1920)
@@ -23,6 +24,7 @@ var Version = "testing"
2324
2425type  appArgs  struct  {
2526	packagesFile     string 
27+ 	playgroundUrl    string 
2628	addr             string 
2729	debug            bool 
2830	buildDir         string 
@@ -39,6 +41,7 @@ func main() {
3941	flag .StringVar (& args .addr , "addr" , ":8080" , "TCP Listen address" )
4042	flag .StringVar (& args .buildDir , "wasm-build-dir" , os .TempDir (), "Directory for WASM builds" )
4143	flag .StringVar (& args .cleanupInterval , "clean-interval" , "10m" , "Build directory cleanup interval" )
44+ 	flag .StringVar (& args .playgroundUrl , "playground-url" , goplay .DefaultPlaygroundURL , "Go Playground URL" )
4245	flag .BoolVar (& args .debug , "debug" , false , "Enable debug mode" )
4346
4447	goRoot , ok  :=  os .LookupEnv ("GOROOT" )
@@ -80,6 +83,7 @@ func start(goRoot string, args appArgs) error {
8083
8184	zap .S ().Info ("Server version: " , Version )
8285	zap .S ().Infof ("GOROOT is %q" , goRoot )
86+ 	zap .S ().Infof ("Playground url: %q" , args .playgroundUrl )
8387	zap .S ().Infof ("Packages file is %q" , args .packagesFile )
8488	zap .S ().Infof ("Cleanup interval is %s" , cleanInterval .String ())
8589	analyzer .SetRoot (goRoot )
@@ -98,7 +102,8 @@ func start(goRoot string, args appArgs) error {
98102	go  store .StartCleaner (ctx , cleanInterval , nil )
99103
100104	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 )).
102107		Mount (r .PathPrefix ("/api" ).Subrouter ())
103108	r .PathPrefix ("/" ).Handler (langserver .SpaFileServer ("./public" ))
104109
0 commit comments