Ankit

While working on some code base, I found out a weird quirk of append built-in function in Golang.

There was a string slice defined and after some operations, the function was returning two things, a string and a string slice.

...
s := []string{"a", "b", "c", "d"}
...
return s[1], append(s[:1], s[1+1:]...)

The output is supposed to be "b" and "a", "c", "d" but what I got was "c" and "a", "c", "d". At first I thought I have discovered a bug but after reading the documentation it became clear that it is intentional. Turns out it has to do with implementation of Slice described in this blog. So, append modifies the underlying array and since arguments are evaluated from right to left, append is executed first which modified the underlying array to become "a", "c", "d" and then s[1] returns the 1st element of the modified array "c".

Check out the code demonstrating the problem in Go playground.

We had a nice day at #work today. Some new people joined and we planned a challenging treasure hunt in #wework building for them. Then families of workmates joined us for a logo designing competition. We then played dumb charades and ate Pizzas together.

This is our third new year together!!!

I exposed my Gitea server to public recently so that I can host my Go packages there and it can still be available to be downloaded by anyone. I still want to keep it private and so I have disabled the registration for now. It is available at git.argc.in.

I finally bought the Interpreter Book on Kindle store.

#learning #programming

A nice write-up about following RFC like process for managing Engineering team at organizations. https://buriti.ca/6-lessons-i-learned-while-implementing-technical-rfcs-as-a-management-tool-34687dbf46cb

I bought and setup a domain argc.in to use as a vanity domain for Golang package imports.

The imports in Golang are the fullpath of the package including the domain name. It is common to host the packages on Github and use it for import as well. However, there are two problems with it.

Read more...

This project is a very simple webapp inspired by Google's internal “go” system. First time I came to know about this was from this Gitlab thread. Also from the same thread I came to know about an open-source implementation of it at kellegous/go.

Read more...

I am challenging myself to do one simple and small project per weekend. There are just two rules I am setting for myself:

  • The base requirements of project must be done in one weekend.
  • The project must require knowledge of atleast one thing which is new for me.

Once I am done with the project, I will explain the idea and working of it in a post here. I am excited, let's see how far I can get.

#weekend #projects