Turning into a Gopher - Week 0: Introduction

Lecture

The first lecture was fairly simple and straightforward. It had two parts wherein the first part the presenter discussed:

  1. The history of Go,

  2. What popular projects are written in Go

  3. Key differences in Go

  4. Some code snippets of simple programs in Go including a simple HTTP server

  5. Comparing Go with Java. Even though I don't have any working knowledge of Java I could fairly read the code since the code snippets were fairly simple.

The second part was more around the structure of the course, what tooling you can use while writing Go, introduction to autocode (the platform for submitting assignments), and a fairly detailed introduction on how to submit solutions to the platform.

autocode - platform to submit homework

The whole point of the lecture I guess was to familiarize folks with Go by giving a high-level introduction to Go and the platform that they would be using throughout phase-1 of the course.

Homework

Since this was an introductory lecture and not much of Go's syntax was taught. The homework was very simple.

Task:

  1. Initialize project with Go modules

  2. Add dependency github.com/kyokomi/emoji to add emojy into the string.

  3. Using Sprint function from this package build a message "Hello πŸ—ΊοΈ!" Hint (code for template engine ":world_map:"):

Solution:

I wrote this solution and pushed the code to the Github repo that got forked to my Github account automatically from autocode platform.

package solution

import (
	"github.com/kyokomi/emoji/v2"
)

func GetMessage() string {
	return emoji.Sprint("Hello :world_map:!")
}

This kept on failing the tests and CI. The error brought me to learn more about go.sum and go.mod which I learned from reading a tutorial on Go Modules.

Finally when I fixed the code and the assignment was successfully submitted.

Just after a successful submission, I realized a different approach to solve the problem which was even more straightforward and was supposed to be taken.

The Github repo had a branch lecture-00 which I was supposed to push code instead of the master repo and it already had a code snippet waiting for me to just add the emoji package and fill in the return statement.

package solution

func GetMessage() string {
	return ""
}

So I did all that effort for nothing. πŸ˜‚

Being an introduction lecture, I did not pick up the textbook since most of the lecture content was mostly around theory and had no hands-on material besides the homework.

That was all for week 0. Gotta Go!


This blog is part of a series of post that I am doing while learning Go. To read more posts from the series check out the introductory post Turning into a Gopher with Golang United School which contains all the posts from the series.

Write a comment ...

Pradhvan Bisht

Show your support

If you enjoy my content please consider supporting it.

Write a comment ...

Pradhvan Bisht

Yet another blog around programming, open-source software, FOSS communities and sometimes life!