From 6b0007cbbb6a7930567f53053f350374ea820d1d Mon Sep 17 00:00:00 2001 From: x1unix Date: Fri, 11 Mar 2022 22:07:52 +0100 Subject: [PATCH 1/7] web: add GoTip option --- web/src/components/settings/SettingsModal.tsx | 72 +++++++++++++------ web/src/services/api.ts | 4 +- web/src/services/config.ts | 5 +- web/src/store/dispatch.ts | 4 ++ 4 files changed, 58 insertions(+), 27 deletions(-) diff --git a/web/src/components/settings/SettingsModal.tsx b/web/src/components/settings/SettingsModal.tsx index b73efe1d..cee3825e 100644 --- a/web/src/components/settings/SettingsModal.tsx +++ b/web/src/components/settings/SettingsModal.tsx @@ -1,19 +1,33 @@ import React from 'react'; -import { Checkbox, Dropdown, getTheme, IconButton, IDropdownOption, Modal } from '@fluentui/react'; -import { Pivot, PivotItem } from '@fluentui/react/lib/Pivot'; -import { MessageBar, MessageBarType } from '@fluentui/react/lib/MessageBar'; -import { Link } from '@fluentui/react/lib/Link'; +import { + Checkbox, + Dropdown, + getTheme, + IconButton, + IDropdownOption, + Modal +} from '@fluentui/react'; +import {Pivot, PivotItem} from '@fluentui/react/lib/Pivot'; +import {MessageBar, MessageBarType} from '@fluentui/react/lib/MessageBar'; +import {Link} from '@fluentui/react/lib/Link'; -import { getContentStyles, getIconButtonStyles } from '~/styles/modal'; +import {getContentStyles, getIconButtonStyles} from '~/styles/modal'; import SettingsProperty from './SettingsProperty'; -import { MonacoSettings, RuntimeType } from '~/services/config'; -import { DEFAULT_FONT, getAvailableFonts } from '~/services/fonts'; -import { BuildParamsArgs, Connect, MonacoParamsChanges, SettingsState } from '~/store'; +import {MonacoSettings, RuntimeType} from '~/services/config'; +import {DEFAULT_FONT, getAvailableFonts} from '~/services/fonts'; +import { + BuildParamsArgs, + Connect, + MonacoParamsChanges, + SettingsState +} from '~/store'; const WASM_SUPPORTED = 'WebAssembly' in window; const COMPILER_OPTIONS: IDropdownOption[] = [ { key: RuntimeType.GoPlayground, text: 'Go Playground' }, + { + key: RuntimeType.GoTipPlayground, text: 'Go Playground (Go Tip)' }, { key: RuntimeType.WebAssembly, text: `WebAssembly (${WASM_SUPPORTED ? 'Experimental' : 'Unsupported'})`, @@ -62,6 +76,7 @@ export interface SettingsProps { interface SettingsModalState { isOpen?: boolean, showWarning?: boolean + showGoTipMessage?: boolean } @Connect(state => ({ @@ -77,7 +92,8 @@ export default class SettingsModal extends React.Component} /> -
- - WebAssembly is a modern runtime that gives you additional features - like possibility to interact with web browser but is unstable. - Use it at your own risk. -

- Seedocumentation for more details. -

-
+
+ { showWarning && ( + + WebAssembly is a modern runtime that gives you additional features + like possibility to interact with web browser but is unstable. + Use it at your own risk. +

+ Seedocumentation for more details. +

+
+ )} + { showGoTipMessage && ( + + Gotip Playground uses the current unstable development build of Go. +

+ Seegotip help for more details. +

+
+ )}
{ - return this.post(`/run?format=${Boolean(format)}`, code); + async evaluateCode(code: string, format: boolean, goTip = false): Promise { + return this.post(`/run?format=${Boolean(format)}&gotip=${Boolean(goTip)}`, code); } async formatCode(code: string): Promise { diff --git a/web/src/services/config.ts b/web/src/services/config.ts index 6bd6e25a..3a4950e3 100644 --- a/web/src/services/config.ts +++ b/web/src/services/config.ts @@ -9,8 +9,9 @@ const MONACO_SETTINGS = 'ms.monaco.settings'; export enum RuntimeType { - GoPlayground = 'GO_PLAYGROUND', - WebAssembly = 'WASM' + GoPlayground = 'GO_PLAYGROUND', + GoTipPlayground = 'GO_TIP_PLAYGROUND', + WebAssembly = 'WASM' } export interface MonacoSettings { diff --git a/web/src/store/dispatch.ts b/web/src/store/dispatch.ts index a6b19b4f..dcaa59b2 100644 --- a/web/src/store/dispatch.ts +++ b/web/src/store/dispatch.ts @@ -120,6 +120,10 @@ export const runFileDispatcher: Dispatcher = const res = await client.evaluateCode(editor.code, settings.autoFormat); dispatch(newBuildResultAction(res)); break; + case RuntimeType.GoTipPlayground: + const rsp = await client.evaluateCode(editor.code, settings.autoFormat, true); + dispatch(newBuildResultAction(rsp)); + break; case RuntimeType.WebAssembly: let resp = await client.build(editor.code, settings.autoFormat); let wasmFile = await client.getArtifact(resp.fileName); From fcb9bfdd699df7965174b343ee22184106493a82 Mon Sep 17 00:00:00 2001 From: x1unix Date: Fri, 11 Mar 2022 22:23:20 +0100 Subject: [PATCH 2/7] server: add support of go tip --- cmd/playground/main.go | 32 ++++++++++------- pkg/goplay/client.go | 5 +-- pkg/langserver/server.go | 74 ++++++++++++++++++++++++++++------------ 3 files changed, 75 insertions(+), 36 deletions(-) diff --git a/cmd/playground/main.go b/cmd/playground/main.go index 006c41b2..8f8e2b28 100644 --- a/cmd/playground/main.go +++ b/cmd/playground/main.go @@ -24,13 +24,15 @@ import ( var Version = "testing" type appArgs struct { - packagesFile string - playgroundUrl string - addr string - debug bool - buildDir string - cleanupInterval string - assetsDirectory string + packagesFile string + playgroundURL string + goTipPlaygroundURL string + addr string + debug bool + buildDir string + cleanupInterval string + assetsDirectory string + connectTimeout time.Duration } func (a appArgs) getCleanDuration() (time.Duration, error) { @@ -49,9 +51,11 @@ func main() { flag.StringVar(&args.addr, "addr", ":8080", "TCP Listen address") flag.StringVar(&args.buildDir, "wasm-build-dir", os.TempDir(), "Directory for WASM builds") flag.StringVar(&args.cleanupInterval, "clean-interval", "10m", "Build directory cleanup interval") - flag.StringVar(&args.playgroundUrl, "playground-url", goplay.DefaultPlaygroundURL, "Go Playground URL") + flag.StringVar(&args.playgroundURL, "playground-url", goplay.DefaultPlaygroundURL, "Go Playground URL") + flag.StringVar(&args.goTipPlaygroundURL, "gotip-playground-url", goplay.DefaultGoTipPlaygroundURL, "GoTip Playground URL") flag.BoolVar(&args.debug, "debug", false, "Enable debug mode") flag.StringVar(&args.assetsDirectory, "static-dir", filepath.Join(wd, "public"), "Path to web page assets (HTML, JS, etc)") + flag.DurationVar(&args.connectTimeout, "timeout", 15*time.Second, "Go Playground server connect timeout") l := getLogger(args.debug) defer l.Sync() //nolint:errcheck @@ -92,7 +96,7 @@ func start(goRoot string, args appArgs) error { zap.S().Info("Server version: ", Version) zap.S().Infof("GOROOT is %q", goRoot) - zap.S().Infof("Playground url: %q", args.playgroundUrl) + zap.S().Infof("Playground url: %q", args.playgroundURL) zap.S().Infof("Packages file is %q", args.packagesFile) zap.S().Infof("Cleanup interval is %s", cleanInterval.String()) zap.S().Infof("Serving web page from %q", args.assetsDirectory) @@ -112,10 +116,14 @@ func start(goRoot string, args appArgs) error { go store.StartCleaner(ctx, cleanInterval, nil) r := mux.NewRouter() - pg := goplay.NewClient(args.playgroundUrl, goplay.DefaultUserAgent, 15*time.Second) - + pgClient := goplay.NewClient(args.playgroundURL, goplay.DefaultUserAgent, args.connectTimeout) + goTipClient := goplay.NewClient(args.goTipPlaygroundURL, goplay.DefaultUserAgent, args.connectTimeout) + clients := &langserver.PlaygroundServices{ + Default: pgClient, + GoTip: goTipClient, + } // API routes - langserver.New(Version, pg, packages, compiler.NewBuildService(zap.S(), store)). + langserver.New(Version, clients, packages, compiler.NewBuildService(zap.S(), store)). Mount(r.PathPrefix("/api").Subrouter()) // Web UI routes diff --git a/pkg/goplay/client.go b/pkg/goplay/client.go index 0ee5c00a..f65b4d7c 100644 --- a/pkg/goplay/client.go +++ b/pkg/goplay/client.go @@ -13,8 +13,9 @@ import ( ) const ( - DefaultUserAgent = "goplay.tools/1.0 (http://goplay.tools/)" - DefaultPlaygroundURL = "https://play.golang.org" + DefaultUserAgent = "goplay.tools/1.0 (http://goplay.tools/)" + DefaultPlaygroundURL = "https://play.golang.org" + DefaultGoTipPlaygroundURL = "https://gotipplay.golang.org" // maxSnippetSize value taken from // https://github.com/golang/playground/blob/master/app/goplay/share.go diff --git a/pkg/langserver/server.go b/pkg/langserver/server.go index efa62dff..dd49a96e 100644 --- a/pkg/langserver/server.go +++ b/pkg/langserver/server.go @@ -6,6 +6,7 @@ import ( "io" "net/http" "strconv" + "strings" "time" "github.com/gorilla/mux" @@ -26,27 +27,33 @@ const ( wasmMimeType = "application/wasm" formatQueryParam = "format" artifactParamVal = "artifactId" + goTipQueryParam = "gotip" ) +type PlaygroundServices struct { + Default *goplay.Client + GoTip *goplay.Client +} + // Service is language server service type Service struct { - version string - log *zap.SugaredLogger - index analyzer.PackageIndex - compiler compiler.BuildService - playground *goplay.Client - limiter *rate.Limiter + version string + log *zap.SugaredLogger + index analyzer.PackageIndex + compiler compiler.BuildService + playgrounds *PlaygroundServices + limiter *rate.Limiter } // New is Service constructor -func New(version string, playground *goplay.Client, packages []*analyzer.Package, builder compiler.BuildService) *Service { +func New(version string, playgrounds *PlaygroundServices, packages []*analyzer.Package, builder compiler.BuildService) *Service { return &Service{ - compiler: builder, - version: version, - playground: playground, - log: zap.S().Named("langserver"), - index: analyzer.BuildPackageIndex(packages), - limiter: rate.NewLimiter(rate.Every(frameTime), compileRequestsPerFrame), + compiler: builder, + version: version, + playgrounds: playgrounds, + log: zap.S().Named("langserver"), + index: analyzer.BuildPackageIndex(packages), + limiter: rate.NewLimiter(rate.Every(frameTime), compileRequestsPerFrame), } } @@ -122,7 +129,7 @@ func (s *Service) provideSuggestion(req SuggestionRequest) (*SuggestionsResponse } // HandleGetVersion handles /api/version -func (s *Service) HandleGetVersion(w http.ResponseWriter, r *http.Request) error { +func (s *Service) HandleGetVersion(w http.ResponseWriter, _ *http.Request) error { WriteJSON(w, VersionResponse{Version: s.version}) return nil } @@ -149,7 +156,7 @@ func (s *Service) HandleFormatCode(w http.ResponseWriter, r *http.Request) error return err } - formatted, _, err := s.goImportsCode(r.Context(), src) + formatted, _, err := s.goImportsCode(r, src) if err != nil { if goplay.IsCompileError(err) { return NewHTTPError(http.StatusBadRequest, err) @@ -165,7 +172,8 @@ func (s *Service) HandleFormatCode(w http.ResponseWriter, r *http.Request) error // HandleShare handles snippet share func (s *Service) HandleShare(w http.ResponseWriter, r *http.Request) error { - shareID, err := s.playground.Share(r.Context(), r.Body) + client := s.getPlaygroundClientFromRequest(r) + shareID, err := client.Share(r.Context(), r.Body) defer r.Body.Close() if err != nil { if err == goplay.ErrSnippetTooLarge { @@ -184,7 +192,8 @@ func (s *Service) HandleShare(w http.ResponseWriter, r *http.Request) error { func (s *Service) HandleGetSnippet(w http.ResponseWriter, r *http.Request) error { vars := mux.Vars(r) snippetID := vars["id"] - snippet, err := s.playground.GetSnippet(r.Context(), snippetID) + client := s.getPlaygroundClientFromRequest(r) + snippet, err := client.GetSnippet(r.Context(), snippetID) if err != nil { if err == goplay.ErrSnippetNotFound { return Errorf(http.StatusNotFound, "snippet %q not found", snippetID) @@ -218,7 +227,7 @@ func (s *Service) HandleRunCode(w http.ResponseWriter, r *http.Request) error { var changed bool if shouldFormat { - src, changed, err = s.goImportsCode(r.Context(), src) + src, changed, err = s.goImportsCode(r, src) if err != nil { if goplay.IsCompileError(err) { return NewHTTPError(http.StatusBadRequest, err) @@ -228,7 +237,8 @@ func (s *Service) HandleRunCode(w http.ResponseWriter, r *http.Request) error { } } - res, err := s.playground.Compile(r.Context(), src) + client := s.getPlaygroundClientFromRequest(r) + res, err := client.Compile(r.Context(), src) if err != nil { return err } @@ -276,6 +286,25 @@ func (s *Service) HandleArtifactRequest(w http.ResponseWriter, r *http.Request) return nil } +func (s *Service) getPlaygroundClientFromRequest(r *http.Request) *goplay.Client { + goTipParam := strings.TrimSpace(r.URL.Query().Get(goTipQueryParam)) + if goTipParam == "" { + return s.playgrounds.Default + } + + goTipEnabled, err := strconv.ParseBool(goTipParam) + if err != nil { + s.log.Debugw("invalid goTip query parameter value, fallback to default", zap.Error(err), zap.String("value", goTipParam)) + return s.playgrounds.Default + } + + if goTipEnabled { + return s.playgrounds.GoTip + } + + return s.playgrounds.Default +} + // HandleCompile handles WASM build request func (s *Service) HandleCompile(w http.ResponseWriter, r *http.Request) error { // Limit for request timeout @@ -299,7 +328,7 @@ func (s *Service) HandleCompile(w http.ResponseWriter, r *http.Request) error { var changed bool if shouldFormat { - src, changed, err = s.goImportsCode(r.Context(), src) + src, changed, err = s.goImportsCode(r, src) if err != nil { if goplay.IsCompileError(err) { return NewHTTPError(http.StatusBadRequest, err) @@ -333,8 +362,9 @@ func (s *Service) HandleCompile(w http.ResponseWriter, r *http.Request) error { // if any error occurs, it sends error response to client and closes connection // // if "format" url query param is undefined or set to "false", just returns code as is -func (s *Service) goImportsCode(ctx context.Context, src []byte) ([]byte, bool, error) { - resp, err := s.playground.GoImports(ctx, src) +func (s *Service) goImportsCode(r *http.Request, src []byte) ([]byte, bool, error) { + client := s.getPlaygroundClientFromRequest(r) + resp, err := client.GoImports(r.Context(), src) if err != nil { if err == goplay.ErrSnippetTooLarge { return nil, false, NewHTTPError(http.StatusRequestEntityTooLarge, err) From ee0f173109dc9bb6792f611b18156b7f1cf3dba8 Mon Sep 17 00:00:00 2001 From: x1unix Date: Fri, 11 Mar 2022 22:35:23 +0100 Subject: [PATCH 3/7] server: add GoTip support --- pkg/langserver/server.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/langserver/server.go b/pkg/langserver/server.go index dd49a96e..a844a7ea 100644 --- a/pkg/langserver/server.go +++ b/pkg/langserver/server.go @@ -299,6 +299,7 @@ func (s *Service) getPlaygroundClientFromRequest(r *http.Request) *goplay.Client } if goTipEnabled { + s.log.Debugw("Using goTip backend for request", zap.String("url", r.RequestURI)) return s.playgrounds.GoTip } From 7f192792c63fcb2905cf7659d0f14d76d571764c Mon Sep 17 00:00:00 2001 From: x1unix Date: Fri, 11 Mar 2022 22:35:37 +0100 Subject: [PATCH 4/7] web: pass gotip param at format --- web/src/services/api.ts | 4 ++-- web/src/store/dispatch.ts | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/web/src/services/api.ts b/web/src/services/api.ts index bf0afc67..b01a8e21 100644 --- a/web/src/services/api.ts +++ b/web/src/services/api.ts @@ -104,8 +104,8 @@ class Client implements IAPIClient { return this.post(`/run?format=${Boolean(format)}&gotip=${Boolean(goTip)}`, code); } - async formatCode(code: string): Promise { - return this.post('/format', code); + async formatCode(code: string, goTip=false): Promise { + return this.post(`/format?gotip=${Boolean(goTip)}`, code); } async getSnippet(id: string): Promise { diff --git a/web/src/store/dispatch.ts b/web/src/store/dispatch.ts index dcaa59b2..92e9863a 100644 --- a/web/src/store/dispatch.ts +++ b/web/src/store/dispatch.ts @@ -1,21 +1,24 @@ -import { saveAs } from 'file-saver'; -import { push } from 'connected-react-router'; +import {saveAs} from 'file-saver'; +import {push} from 'connected-react-router'; import { Action, - ActionType, MonacoParamsChanges, newBuildParamsChangeAction, + ActionType, + MonacoParamsChanges, + newBuildParamsChangeAction, newBuildResultAction, newErrorAction, newImportFileAction, - newLoadingAction, newMonacoParamsChangeAction, + newLoadingAction, + newMonacoParamsChangeAction, newProgramWriteAction, newToggleThemeAction, newUIStateChangeAction } from './actions'; -import client, { EvalEventKind, instantiateStreaming } from '~/services/api'; -import config, { RuntimeType } from '~/services/config'; -import { DEMO_CODE } from '~/components/editor/props'; -import { getImportObject, goRun } from '~/services/go'; -import { State } from './state'; +import client, {EvalEventKind, instantiateStreaming} from '~/services/api'; +import config, {RuntimeType} from '~/services/config'; +import {DEMO_CODE} from '~/components/editor/props'; +import {getImportObject, goRun} from '~/services/go'; +import {State} from './state'; export type StateProvider = () => State export type DispatchFn = (a: Action | any) => any @@ -147,8 +150,11 @@ export const formatFileDispatcher: Dispatcher = async (dispatch: DispatchFn, getState: StateProvider) => { dispatch(newLoadingAction()); try { - const { code } = getState().editor; - const res = await client.formatCode(code); + // Format code using GoTip is enabled to support + // any syntax changes from unstable Go specs. + const { editor: {code}, settings: { runtime } } = getState(); + const isGoTip = runtime === RuntimeType.GoTipPlayground; + const res = await client.formatCode(code, isGoTip); if (res.formatted) { dispatch(newBuildResultAction(res)); From 904b85db59929cacc63bc2a20834f42111afe120 Mon Sep 17 00:00:00 2001 From: x1unix Date: Fri, 11 Mar 2022 22:43:50 +0100 Subject: [PATCH 5/7] use 'backend' query param for backend selection --- pkg/langserver/server.go | 23 +++++++---------------- web/src/services/api.ts | 13 +++++++++---- web/src/store/dispatch.ts | 12 ++++++++---- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pkg/langserver/server.go b/pkg/langserver/server.go index a844a7ea..e4a0a4c2 100644 --- a/pkg/langserver/server.go +++ b/pkg/langserver/server.go @@ -24,10 +24,11 @@ const ( frameTime = time.Second maxBuildTimeDuration = time.Second * 30 - wasmMimeType = "application/wasm" - formatQueryParam = "format" - artifactParamVal = "artifactId" - goTipQueryParam = "gotip" + wasmMimeType = "application/wasm" + formatQueryParam = "format" + artifactParamVal = "artifactId" + playgroundBackendParam = "backend" + playgroundGoTip = "gotip" ) type PlaygroundServices struct { @@ -287,18 +288,8 @@ func (s *Service) HandleArtifactRequest(w http.ResponseWriter, r *http.Request) } func (s *Service) getPlaygroundClientFromRequest(r *http.Request) *goplay.Client { - goTipParam := strings.TrimSpace(r.URL.Query().Get(goTipQueryParam)) - if goTipParam == "" { - return s.playgrounds.Default - } - - goTipEnabled, err := strconv.ParseBool(goTipParam) - if err != nil { - s.log.Debugw("invalid goTip query parameter value, fallback to default", zap.Error(err), zap.String("value", goTipParam)) - return s.playgrounds.Default - } - - if goTipEnabled { + playgroundBackend := strings.TrimSpace(r.URL.Query().Get(playgroundBackendParam)) + if playgroundBackend == playgroundGoTip { s.log.Debugw("Using goTip backend for request", zap.String("url", r.RequestURI)) return s.playgrounds.GoTip } diff --git a/web/src/services/api.ts b/web/src/services/api.ts index b01a8e21..b3a18f57 100644 --- a/web/src/services/api.ts +++ b/web/src/services/api.ts @@ -6,6 +6,11 @@ import config from './config'; const apiAddress = `${config.serverUrl}/api`; const axiosClient = axios.default.create({ baseURL: apiAddress }); +export enum PlaygroundBackend { + Default = '', + GoTip = 'gotip' +} + export enum EvalEventKind { Stdout = 'stdout', Stderr = 'stderr' @@ -100,12 +105,12 @@ class Client implements IAPIClient { return resp; } - async evaluateCode(code: string, format: boolean, goTip = false): Promise { - return this.post(`/run?format=${Boolean(format)}&gotip=${Boolean(goTip)}`, code); + async evaluateCode(code: string, format: boolean, backend = PlaygroundBackend.Default): Promise { + return this.post(`/run?format=${Boolean(format)}&backend=${backend}`, code); } - async formatCode(code: string, goTip=false): Promise { - return this.post(`/format?gotip=${Boolean(goTip)}`, code); + async formatCode(code: string, backend = PlaygroundBackend.Default): Promise { + return this.post(`/format?backend=${backend}`, code); } async getSnippet(id: string): Promise { diff --git a/web/src/store/dispatch.ts b/web/src/store/dispatch.ts index 92e9863a..36dce10b 100644 --- a/web/src/store/dispatch.ts +++ b/web/src/store/dispatch.ts @@ -14,7 +14,11 @@ import { newToggleThemeAction, newUIStateChangeAction } from './actions'; -import client, {EvalEventKind, instantiateStreaming} from '~/services/api'; +import client, { + EvalEventKind, + instantiateStreaming, + PlaygroundBackend +} from '~/services/api'; import config, {RuntimeType} from '~/services/config'; import {DEMO_CODE} from '~/components/editor/props'; import {getImportObject, goRun} from '~/services/go'; @@ -124,7 +128,7 @@ export const runFileDispatcher: Dispatcher = dispatch(newBuildResultAction(res)); break; case RuntimeType.GoTipPlayground: - const rsp = await client.evaluateCode(editor.code, settings.autoFormat, true); + const rsp = await client.evaluateCode(editor.code, settings.autoFormat, PlaygroundBackend.GoTip); dispatch(newBuildResultAction(rsp)); break; case RuntimeType.WebAssembly: @@ -153,8 +157,8 @@ export const formatFileDispatcher: Dispatcher = // Format code using GoTip is enabled to support // any syntax changes from unstable Go specs. const { editor: {code}, settings: { runtime } } = getState(); - const isGoTip = runtime === RuntimeType.GoTipPlayground; - const res = await client.formatCode(code, isGoTip); + const backend = runtime === RuntimeType.GoTipPlayground ? PlaygroundBackend.GoTip : PlaygroundBackend.Default; + const res = await client.formatCode(code, backend); if (res.formatted) { dispatch(newBuildResultAction(res)); From 3417a73a4aaf06870fbe4d72d072fd2ab9608cb9 Mon Sep 17 00:00:00 2001 From: x1unix Date: Fri, 11 Mar 2022 22:46:58 +0100 Subject: [PATCH 6/7] cmd: simplify gotip address flag --- cmd/playground/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/playground/main.go b/cmd/playground/main.go index 8f8e2b28..ea825d81 100644 --- a/cmd/playground/main.go +++ b/cmd/playground/main.go @@ -52,7 +52,7 @@ func main() { flag.StringVar(&args.buildDir, "wasm-build-dir", os.TempDir(), "Directory for WASM builds") flag.StringVar(&args.cleanupInterval, "clean-interval", "10m", "Build directory cleanup interval") flag.StringVar(&args.playgroundURL, "playground-url", goplay.DefaultPlaygroundURL, "Go Playground URL") - flag.StringVar(&args.goTipPlaygroundURL, "gotip-playground-url", goplay.DefaultGoTipPlaygroundURL, "GoTip Playground URL") + flag.StringVar(&args.goTipPlaygroundURL, "gotip-url", goplay.DefaultGoTipPlaygroundURL, "GoTip Playground URL") flag.BoolVar(&args.debug, "debug", false, "Enable debug mode") flag.StringVar(&args.assetsDirectory, "static-dir", filepath.Join(wd, "public"), "Path to web page assets (HTML, JS, etc)") flag.DurationVar(&args.connectTimeout, "timeout", 15*time.Second, "Go Playground server connect timeout") From a3db523c6a9034af7799d1d7e0f432577d1e0bc0 Mon Sep 17 00:00:00 2001 From: x1unix Date: Fri, 11 Mar 2022 22:47:26 +0100 Subject: [PATCH 7/7] docker: add gotip url environment variable --- build/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index 7bda7fe8..10eed988 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -24,7 +24,8 @@ WORKDIR /opt/playground ENV GOROOT /usr/local/go ENV APP_CLEAN_INTERVAL=10m ENV APP_DEBUG=false -ENV APP_PLAYGROUND_URL=https://play.golang.org +ENV APP_PLAYGROUND_URL='https://play.golang.org' +ENV APP_GOTIP_URL='https://gotipplay.golang.org' COPY data ./data COPY --from=ui-build /tmp/web/build ./public COPY --from=build /tmp/playground/server . @@ -32,4 +33,4 @@ COPY --from=build /tmp/playground/worker.wasm ./public COPY --from=build /tmp/playground/wasm_exec.js ./public EXPOSE 8000 ENTRYPOINT /opt/playground/server -f=/opt/playground/data/packages.json -addr=:8000 \ - -clean-interval=${APP_CLEAN_INTERVAL} -debug=${APP_DEBUG} -playground-url=${APP_PLAYGROUND_URL} \ No newline at end of file + -clean-interval=${APP_CLEAN_INTERVAL} -debug=${APP_DEBUG} -playground-url=${APP_PLAYGROUND_URL} -gotip-url=${APP_GOTIP_URL} \ No newline at end of file