SoFunction
Updated on 2025-03-03

From Go to Go Platform

After establishing the first iteration of Bowery with, we switched to Go in February 2014, and our development and deployment speeds have been improved.

Since then, our entire team has become a full-time gopher. Go's clear standards and easier workflow make it comfortable to use Go. Here are the reasons why we love working with Go, from which you can take a look at our gopher hole.

Easy to write cross-platform code

One of the biggest reasons we switched to Go is that it is so easy to compile code for different systems.

At Bowery, we are building an app that can help you and your team manage your development environment, and we must efficiently support all operating systems - Linux, Windows, and OSX. In Go, you can define different files for different operating systems to achieve operating system-dependent functions. An excellent example is the fact that our companion Larz is building a package Prompt that reads user input from the command line. Larz hopes to create a Go package to implement cross-platform line editing prompts. This is so simple in Go: create different files for each operating system, and the Go compiler selects the files to use based on the operating system to generate the final content.

Compiling code for other systems is also simple. All you have to do is set an environment variable and then you have a Windows binary that you compile on a Linux system.

Faster deployment

Go is a compiled language and makes it easier to distribute applications on multiple platforms. Deployment and testing are important to us and are also an asset to our end users. With Go, it will be easy to build a service and then run tests, because it is ready when migrating to a server in your production environment. Go does not require any system dependencies, making it release really easy. When publishing command line tools or other applications, our users do not need to worry about installing Java, RVM or NPM to run. We like this article by Jeremy Saenz, who discusses why he migrated all of his command line tools to Go (CLI tools to Go).

Concurrent primitives
The event loop we realize when switching to Go is not everything. Not providing much concurrent primitives. The only ones that can run at the same time are I/O programs and timers. You cannot communicate through these programs, so building an agile system is a challenge. With Go, you can provide a channel to send a signal to the program to do something, or send them some values ​​to share data while running any program. Go also provides low-level concurrent primitives such as mutexes, wait groups, etc. Some of them you may find on NPM, but we found that channels are the decisive factor when dealing with concurrency and parallelism.

Integrated testing framework

When using it, we already have our test framework choices, but some frameworks are better for the front-end, such as Jasmine, and others are better for the back-end, such as Mocha. There are other options like JSUnit and PhantomJS. If you have read this article on *, there are also many frameworks that recommend. In some worlds, choosing is a good thing, but when using Go, we like to normalize the test framework. In Go, all test packages are built-in. If you need to write a new test suite, you have to do it by adding the (filename)_test.go file to the same package of the software you are testing, and it will run every time you execute go test.
You can learn more about Go testing in writing tests with Go. Need to test HTTP services? Go also provides the httptest package

Standard library

We like to write most software using Go's standard library alone. When used, we almost always had to introduce an external library. This not only increases the deployment time but also increases potential risks from third-party software. Using only the standard library can make the code we write faster and safer.

Workflow tools for developers are more powerful

Apart from NPM's packages and script controls, there is no real standardized workflow. Besides that, because these tools are created by the community, they are so useful that there are so many that the end result is that things are done differently by everyone. A good example of workflow standardization in Go is the layout of workspaces. You have to give up a lot of development freedom because you have to adhere to the workspace layout, but it provides a lot of structure: you can keep your Go source code and dependencies in the same place. In your workspace you have 3 root directories: src puts the source package, pkg puts the compiled package, and bin puts executable programs. Having your source code and dependencies in a separate workspace is a best practice, making it the standard on everyone's machine. These predictability is satisfying in teamwork. We can go to anyone's machine to help and know that our code will appear in the path $GOPATH/src//Bowery, not other paths like $HOME/some/path/to/Bowery. Similarly, gofmt formats everyone's code in the same way. For some superficial issues, such as organizational code and code style differences, there is no need to worry about in Go, which is a great liberation. You can focus on fixing your problems, and everything else is considered.

There are a lot of other reasons to like Go. We are seeing more and more companies adopt Go to make internal applications more powerful and distributed. But overall, the Go team found that developers would be more productive if you create standards and make examples to let others agree. For example, MongoDB's application management team likes to use Go's "wise, unified development experience". At Soundcloud, they like the philosophy of using Go's strict rules for formatting code and "there is only one way to implement it". This means you spend very little time on code review and arguing about code style and format, and you can spend more time solving the root cause of your problem.

If you're just starting out with Go and want to learn more, here are some resources to check out.

Read updates to Golang's official blog and announcements from the core team
Reading core team provides learning documents on the official website
We love the tips and guides written by Bill Kennedy of Ardan Studios on the blog Going Go Programming
Go by Example There are a bunch of examples of different tasks written in Go
GopherAcademy has many articles on best practices about Go
Brian McCallister has a good article about Go workspace and overall development environment
More about Go's code organization, read the article posted by Jared Carroll on Pivotal Labs blog
If you are starting your first Go project, set up your new environment and share it with your team in Bowery.

Please take some time to share the article with your friends or leave a comment. We will sincerely thank you for your support!