TIL what bare git repositories and git worktrees are

Git has this feature called bare repositories. After a normal clone, along with our project files, there's a `.git` hidden directory. Going into the .git directory, we can see all the folders and files that git keeps to do our version control.

A bare repo, doesn't have our project files and only has the folders and files in the above image. When we clone a repo, if we add `--bare` to the clone command, we make a bare repo.

Why do this?
For one, we can clone off of a bare repo:

git clone --bare /home/ilango/aurelius aurelius_2

Note that the I'm cloning a repo from a local folder. This is useful for collaboration when we have a shared storage in a local network and don't want to host our project in the cloud.

What made me more interested in bare repos is worktrees. Git worktrees are one of the lesser known but coolest features. It allows us to have unfinished work in multiple branches at the same time, without having to use `git stash`.

For example, let's say you're in `feature-branch-1`, and are made aware of a bug in `main`. You have unstaged work in feature-branch-1, so you run `git stash`, checkout to main, fix the bug, come back to the feature branch and run `git stash pop`. With worktrees, we don't need to do all this.

Instead of a normal clone, do a bare clone,  and run

git worktree add main main

Note: first "main" is the folder name, second "main" is the branch name. Also note, the main folder in the image. That's my main branch worktree.

This creates a main folder in your bare repo. Changing to this repo we can see that the main folder contains our main branch! We can do this for as many branches as we want and switch between them with different changes. We don't need bare repositories for using git worktrees but it keeps my folder structure cleaner.

More details here: https://git-scm.com/docs/git-worktree

TIL in Golang: Identifying Isograms & difference of squares

I did a couple of simple exercises on Exercism — identifying isograms and difference of squares.

After I finished them, I checked the community solutions and realized how brute-forced, inefficient my solution was. But that's the process of learning.

By checking community solutions, I learned about two methods available in the standard library: IsLetter and ContainsRune!

TIL in Golang: Time, Type Conversion & Assertion, First class functions

Time package in Golang is, honestly, the most pain-in-the-ass, annoying shit ever. I did NOT have a good time debugging issues in the exercise. The other ones were pretty clear, mostly. Type Assertion also made me pull my hair out a bit, but not as much as time. xD

Fortunately, time was the last concept I had to learn in the Go syllabus on Exercism. Now on to the other exercises, 1 or 2 a day. Also, it's time to dive into some projects from this project-based learning repo: https://github.com/practical-tutorials/project-based-learning#go

Time: https://exercism.org/tracks/go/exercises/booking-up-for-beauty/solutions/ilango
Type Conversion & Assertion: https://exercism.org/tracks/go/exercises/sorting-room/solutions/ilango
First class functions: https://exercism.org/tracks/go/exercises/expenses/solutions/ilango

TIL in Golang: Interfaces & Errors

This one was a bit hard to get my head around. There was one common exercise for both of these concepts. But while working on the exercise itself, I realized how important these concepts were, especially if I'm working on projects or public packages.

So there is no exceptions for error handling in Go. Instead errors are values of an interface called `error`. In order to learn errors, I had to learn interfaces.

I still need more practice on these two topics because I feel my understanding of them is a bit shaky. Anyways, here's my solution:


TIL in Golang: Regular Expressions

I don't like working with regular expressions much although I've written a fair share of them. But today's Go lesson on regular expressions is the most fun I've had with them.

The exercise is parsing logs and cleaning up logs. We have to write a bunch of functions that does different cleaning up and organizing tasks.

Solution: https://exercism.org/tracks/go/exercises/parsing-log-files/solutions/lbcosta

TIL in Golang: Methods & Runes

Today's lessons were Methods and Runes.

Pretty simple exercises but took me a bit of time to figure out a few issues, especially in runes.

Runes: https://exercism.org/tracks/go/exercises/logs-logs-logs/solutions/ilango
Methods: https://exercism.org/tracks/go/exercises/elons-toys/solutions/ilango

TIL in Golang: Pointers

I haven't done anything with pointers since my C++ days and that was years back.

Anyways, today's Golang lesson was Pointers. The exercise was to build a simplified digital vote counting system for a students' association president election.

Here's my solution (SPOILERS): https://exercism.org/tracks/go/exercises/election-day/solutions/ilango

TIL in Golang: Range Iteration & Type Definitions

Going through the Go track syllabus on exercism.org.

Today's lessons were Range Iteration and Type Definitions. Both have a common exercise, which was to generate a simple chessboard and do small calculations on it.

Here's my solution (SPOILERS): https://exercism.org/tracks/go/exercises/chessboard/solutions/ilango

Regarding privacy concerns, it's simple - we don't sell your data. In fact, we try to use privacy-focused software/services like Fathom Analytics whenever we use any third-party services.