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

Dependency injections

The server-side application's primary entry point is the main function defined in the igweb.go source file. The client-side application's primary entry point is the main function defined in the client/client.go source file. In both of these primary entry points, we utilize a dependency injection technique to share a common functionality throughout the web application. By doing so, we avoid having to utilize package-level global variables.

On both the server side, and on the client side, we implement a custom Env type in the common package. You may consider that Env stands for the common functionality that is to be accessed from the application environment.

Here's the declaration of the Env struct on the server side, ...

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