Don’t use Golang

Golang is a trend now but there is a lot of projects where you have to avoid of using it.

Let’s start from what kind of benefits brings Golang for your team/project:

– Easy to learn and get started with. This helps to grow your team quickly and involve new people even without any experience with Golang.

– Built-in concurrency and a robust standard library. Which allows to utilise your CPU in the most effective way and easily create multithreading applications (channels, mutex, atomic etc.).

– Strict types helps to avoid some basic coding issues. So these options shows us that Golang is a good tool for high performance projects and big growing teams.

But otherwise when your team is small and you don’t need to solve high performance tasks. That means that you will have some troubles like a very big codebase.

– Lack of generics in Golang will make you to write / support more code.

– Writing of multithreading programms even in Golang requires to have senior engineers. So that means you will have to spend more money on your team without any incomes from using Golang.

– It will take more time to release because you will need to write/support a bigger codebase.


When you don’t need to use Golang in your team/project?

– Your project is not simple (it is not quite small like some CLI utilities or small service) and it should be build as a monolithic application with a small team

– Your budget is not big and you don’t have too much time for release

– Your project is new and you have to release it ASAP to make money

– You don’t have any high performance problems which can not be solved on your current technical stack

App build fail fix for session_srtp.go:144:9: assignment mismatch: 1 variable but h.Unmarshal returns 2 values

# github.com/pion/srtp/v2
../../../../1.16.2/pkg/mod/github.com/pion/srtp/v2@v2.0.2/session_srtp.go:144:9: assignment mismatch: 1 variable but h.Unmarshal returns 2 values
../../../../1.16.2/pkg/mod/github.com/pion/srtp/v2@v2.0.2/srtp.go:37:9: assignment mismatch: 1 variable but header.Unmarshal returns 2 values
../../../../1.16.2/pkg/mod/github.com/pion/srtp/v2@v2.0.2/srtp.go:52:9: assignment mismatch: 1 variable but header.Unmarshal returns 2 values
../../../../1.16.2/pkg/mod/github.com/pion/srtp/v2@v2.0.2/srtp.go:56:51: header.PayloadOffset undefined (type *rtp.Header has no field or method PayloadOffset)
../../../../1.16.2/pkg/mod/github.com/pion/srtp/v2@v2.0.2/srtp_cipher_aead_aes_gcm.go:99:13: header.PayloadOffset undefined (type *rtp.Header has no field or method PayloadOffset)
../../../../1.16.2/pkg/mod/github.com/pion/srtp/v2@v2.0.2/srtp_cipher_aead_aes_gcm.go:104:18: header.PayloadOffset undefined (type *rtp.Header has no field or method PayloadOffset)
../../../../1.16.2/pkg/mod/github.com/pion/srtp/v2@v2.0.2/srtp_cipher_aes_cm_hmac_sha1.go:121:30: header.PayloadOffset undefined (type *rtp.Header has no field or method PayloadOffset)
../../../../1.16.2/pkg/mod/github.com/pion/srtp/v2@v2.0.2/srtp_cipher_aes_cm_hmac_sha1.go:126:32: header.PayloadOffset undefined (type *rtp.Header has no field or method PayloadOffset)
../../../../1.16.2/pkg/mod/github.com/pion/srtp/v2@v2.0.2/stream_srtp.go:88:6: assignment mismatch: 1 variable but header.Unmarshal returns 2 values

While working on the one of my pet projects I caught the issue with building of my app. The fix is very easy but I spent some time to find out the issue and how to solve it.

So if you have the same issue you have to add to your go.mod file such line:

github.com/pion/srtp/v2 v2.0.5 // indirect

And update your packages with go mod. The problem was on this line – https://github.com/pion/srtp/compare/v2.0.4…v2.0.5#diff-42e63a61fe336233215c8623a90b1e1697a38e30aa9cafc1c396a9e37d61c00cR144

Golang library for MongoDB (DBAL)

Here is my DBAL implementation for mongoDB that I am using in my daily routines.

It contains features that I am using frequently it does not contain any implementation for DSL or Query Builders.

All extra features will be added later or maybe I will put it into a different library.

https://github.com/wajox/mongol

CloneGoPkg – CLI tool to create new package from template in git repository

CloneGoPkg is a simple CLI tool to create your own package from template based on any git repository

Install

go install -i github.com/wajox/clonegopkg

Usage

# clonegopkg clone [git_repository_template] [new_pkg]
clonegopkg clone git@github.com:wajox/gobase.git github.com/wajox/newproject

Sources

GitHub – https://github.com/wajox/clonegopkg

Golang Application Template

Here is my template for Golang Application – https://github.com/ildarusmanov/gobase https://github.com/wajox/gobase

Only one thing that you have to do after git clone – replace all package name entries, from github.com/ildarusmanov/gobase github.com/wajox/gobase to [your_package_name]

UPD:

Template has been updated and moved into wajox/gobase repository.

IT Nights — ночная конференция в Иннополисе

Приглашаю всех на ИТ конференцию в г.Иннополис 🙂

АНОНС МЕРОПРИЯТИЯ:

1–3 АВГУСТА 
ИННОПОЛИС, РЕСПУБЛИКА ТАТАРСТАН

IT Nights – Первая ночная конференция 
для ИТ-специалистов. 
Потому что ночью происходит 
всё самое интересное. 

https://it-nights.ru

ПОДРОБНЕЕ О ГОРОДЕ:

Иннопо́лис — город в Верхнеуслонском районе Республики Татарстан, город-спутник Казани, входящий в её агломерацию. В поселении расположены Университет Иннополис и особая экономическая зона «Иннополис». 

http://www.innopolis.com

From Rails to KrakenD proxy: config generation for your routes

require "action_dispatch/routing/inspector"

begin
  namespace :krakend do
    task :routes => :environment do

      inspector = ActionDispatch::Routing::RoutesInspector.new(Rails.application.routes.routes)
      formatter = CustomRoutesFormatter.new
      routes_filter = {}

      puts inspector.format(formatter, routes_filter)
    end
  end
end

class CustomRoutesFormatter < ActionDispatch::Routing::ConsoleFormatter::Expanded
  def section_title(title)
  end

  def section(routes)
    @buffer << draw_expanded_section(routes)
  end

  private

  def draw_expanded_section(routes)
    routes.map.each_with_index do |r, i|
      path = r[:path].gsub("(.:format)", "").gsub(/:([a-z_]*)/, "{\\1}")

      <<~MESSAGE.chomp
        {
          "endpoint": "#{path}",
          "method": "#{r[:verb]}",
          "querystring_params": ["*"],
          "extra_config": {},
          "output_encoding": "no-op",
          "concurrent_calls": 1,
          "headers_to_pass": ["*"],
          "backend": [
            {
              "url_pattern": "#{path}",
              "encoding": "no-op",
              "extra_config": {},
              "sd": "static",
              "host": [
                "http://rails-app"
              ],
              "disable_host_sanitize": true
            }
          ]
        },
      MESSAGE
    end
  end
end

This approach can help you easily build krakend.json for your rails application.

GopherCon 2019

Побывали на Российской ГоферКонфе 🙂

Было очень полезно и интересно, очень понравились доклады от Konrad Reiche(go generate: One File to Rule Them All) и Денис Исаев(Линтеры в Go: как их готовить).

http://gophercon-russia.ru

Golang Hints: Create MongoDB Object ID from String

Sometimes you may want to find something by the Object ID in your MongoDB and due to you URI or query string contains ID you should convert the string ID to Object ID.

Below is a code that converts string ID to Object ID:

 package main

import (
"go.mongodb.org/mongo-driver/bson/primitive"
"fmt"
)
func main() {
oid, err := primitive.ObjectIDFromHex(recordID)

fmt.Printf("%s %v", err, oid)

  // if err := collection.FindOne(ctx, bson.M{"_id": oid}).Decode(e); err != nil {
  // return nil, err
// }
}