Go Db2: Application Development with Db2 and Go Language

2 min read

There are many important factors when choosing a database, and different roles within the organization may have different priorities.

Among the different perspectives, the CFO might be interested in commercial considerations (e.g., license, support, hardware footprint), the CEO might be interested in stability and performance, and developers like to use databases that enable them to build faster and better.

If you are looking for new, innovative tools to develop backend database applications, read on. IBM has published a Go language driver on GitHub that facilitates rapid database application development with Db2.

Why use Go?

Many well-known applications and tools are implemented in Go language; for example, Docker, Kubernetes, and Terraform are all written in Go. Even Red Hat OpenShift, IBM's choice of container platform, is written in Go.

The Go programming language was designed at Google in 2007. The goal was to improve programming productivity and to address some of the problems of C/C++. Some important Go features include automatic garbage collection (to avoid memory leaks) and memory safety (pointers cannot be modified).

The good news for all C/C++ programmers is that, syntactically, Go is very similar to C but uses a more simplified syntax. And, the good news for all the Python fans out there is that Go provides a build-in map type which is similar to the dictionary type in Python. There is also a Go interpreter available that facilitates rapid prototyping. A key differentiator from Python, however, is that Go uses static typing, which helps to detect errors early on in the development cycles. In addition, Go is orders of magnitude faster than Python.

So far, we talked about developer needs. The next section is more for the CEO and CFO.

Why use Db2?

When Db2 compression was invented, it significantly reduced the storage footprint while retaining performance. SAP customers, especially, migrated to Db2 to benefit from storage and memory savings. Another milestone was Db2 pureScale, which added horizontal scale-out options for OLTP workloads. Later on, Db2 BLU (a columnar database engine) was added to accelerate analytic workloads. Many customers started to sunset their in-memory analytic accelerators and adopted Db2 BLU.

What is the latest Db2 move? It is the move to the cloud! Db2 now runs containerized on OpenShift. Since OpenShift is supported by all major cloud providers, customers can easily move their Db2 databases across clouds.

Get started with Db2 and Go

In summary, Go language and Db2 are a great match. They enable developers to rapidly build database applications and help to reduce programming errors. The speed of compiled Go programs and Db2 enables customers to build fast and modern transactional and analytic applications in the cloud.

If you’d like to begin working with Go and Db2, take the free Go-Db2 programming lab in the IBM cloud. The lab environment has everything pre-installed: Go, Db2, the Db2-Go driver, and Jupyter notebooks with lab instructions that allow you to interactively try out Go code examples. You also find advanced Db2-Go code that shows for example how to work with Db2 cursors and Db2 parameter markers.

For other database labs, visit IBM Demos and select the Hybrid Data Management segment

Be the first to hear about news, product updates, and innovation from IBM Cloud