So far, we have covered how to write our frontend using JavaScript. However, if you prefer to use Go in the frontend, there is an option for that. This option is known as GopherJS, which is a popular Go package combined with a set of commands with only one purpose: to compile (also known as transpiling) Go code to JavaScript. Once Go code is compiled to JavaScript, the code could be utilized in the frontend component similarly to JavaScript. An application that relies on the same programming language for the frontend and the backend is known as an isomorphic application.
Like any other software-design approach, writing isomorphic applications has its own pros and cons. The chief advantage is the convenience and speed of development that comes with using a single programming language that you are really good at for most of your code. The main disadvantage is the difficulty of troubleshooting non-trivial issues, since you will have to dive into the generated JavaScript code.
This chapter is an introduction to isomorphic web development. We will cover some of the key building blocks of GopherJS, and how you can make use of it to write code that can interact with both web browsers and Node.js modules. We will also cover how to write a simple React application powered by GopherJS, and some open source projects.
In this chapter, we will cover the following topics:
- GopherJS fundamentals
- GopherJS with React