Skip to content

Commit d12bf38

Browse files
committed
Set URL only if CG_GAME_URL is present
1 parent 6877e94 commit d12bf38

File tree

4 files changed

+6
-18
lines changed

4 files changed

+6
-18
lines changed

new/client/client.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ var wrapperGameTemplate string
2727
//go:embed templates/wrappers/events.go.tmpl
2828
var wrapperEventsTemplate string
2929

30-
//go:embed templates/wrappers/game.go.init-dev.tmpl
31-
var wrapperGameInitDevTemplate string
32-
33-
//go:embed templates/wrappers/game.go.init-build.tmpl
34-
var wrapperGameInitBuildTemplate string
35-
3630
func CreateNewClient(projectName, gameName, serverURL, libraryVersion string, generateWrappers bool) error {
3731
module, err := cli.Input("Project module path:")
3832
if err != nil {
@@ -146,14 +140,12 @@ func execClientWrappersTemplate(projectName, modulePath, gameName, serverURL, li
146140
PackageName string
147141
ModulePath string
148142
Events []event
149-
InitFunc string
150143
}{
151144
URL: serverURL,
152145
LibraryURL: libraryURL,
153146
PackageName: gamePackageName,
154147
ModulePath: modulePath,
155148
Events: events,
156-
InitFunc: wrapperGameInitDevTemplate,
157149
}
158150

159151
err := new.ExecTemplate(wrapperMainTemplate, filepath.Join("main.go"), data)

new/client/templates/wrappers/game.go.init-build.tmpl

Lines changed: 0 additions & 6 deletions
This file was deleted.

new/client/templates/wrappers/game.go.init-dev.tmpl

Lines changed: 0 additions & 3 deletions
This file was deleted.

new/client/templates/wrappers/game.go.tmpl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import (
1919

2020
var URL string
2121

22-
{{.InitFunc}}
22+
func init() {
23+
url := os.Getenv("CG_GAME_URL")
24+
if url != "" {
25+
URL = url
26+
}
27+
}
2328

2429
type Game struct {
2530
Id string

0 commit comments

Comments
 (0)