Golang with Examples: Keeping Your Modules Compatible

Golang with Examples: Keeping Your Modules Compatible

Learn how to extend Functions and Interfaces without breaking behaviour & ensuring backward compatibility. Golang with Examples: Keeping Your Modules Compatible

TLDR;

  • When extending a function, NEVER change the function signature
  • Make sure you have thought about the future uses before exposing an Interface to public, because you’re NEVER gonna change that
  • There’s Backward Compatibility (code can compile) and Behaviour Compatibility (code acts the same way) to consider

Background

In this world, we have two kinds of repositories:

  1. Application Repositories — repositories that is only used & seen by you and your team that contains the business logic of your App
  2. Shared Libraries — Repositories that are used by many other application repositories (think any standard library, SQL package, Redis, any open source pkg etc…)

Because many application repositories rely so heavily on Shared Libraries, we need to make extra care when writing them to 1) maintain readability and most importantly, 2) ensure backward compatibility.

This blog post hopes to provide junior devs with an illustration of the concepts taught in the Golang blog’s latest post:  https://blog.golang.org/module-compatibility. I will first show simple examples of the patterns discussed and also point to some examples already illustrating these points.

golang clean-code golang-development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Golang Web Development:Th Best Programming Language in 2020

Golang Web Development is the new trend globally. Get all the details about the Golang development here. Hire Golang Developers.

How long does it take to develop/build an app?

This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.

Developer Career Path: To Become a Team Lead or Stay a Developer?

For a developer, becoming a team leader can be a trap or open up opportunities for creating software. Two years ago, when I was a developer, ... by Oleg Sklyarov, Fullstack Developer at Skyeng company

Is Low-code or no-code development is future of mobile app development

Mobile app development has skyrocketed over these years with the increasing demand of mobile apps for a variety of purposes like entertainment, banking, weather update, health, booking movie tickets, booking a taxi etc. With the latest...

Embold Is Like Autocorrect For Code, Says Vishal Rai, Founder & CEO

We, at Analytics India Magazine, spoke to founder and CEO, Vishal Rai, to understand how Embold can detect anti-patterns in code for seamless integration. Embold started a decade ago, with the vision of creating a product that can revolutionise the way developers write and design code.