O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

GopherJS-produced JavaScript source file

Inside the funcs.go source file where our template functions are defined, we introduce a new function called IsProduction:

func IsProduction() bool {  if isokit.OperatingEnvironment() == isokit.ServerEnvironment {    return os.Getenv("IGWEB_MODE") == "production"  } else {    return false  }}

This function, meant to be used on the server-side, will return a value of true if the current operating mode is production, and false if it isn't. We can use this custom function within a template to determine from where the client-side JavaScript application should be obtained.

When operating in non-production mode, the client.js source file will be obtained from the server relative path of /js/client.js. In production ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required