GO 101: Day 1
Dat One Dev

Dat One Dev @dat_one_dev

About: Just a programmer , creator , student and your friend

Joined:
Feb 21, 2025

GO 101: Day 1

Publish Date: May 31
0 0

Story of Rust

Backend, the darkest valley of the coding world. In a world where people love to pet snakes(such people are called Pythons), some love the smell of fear, the tears of pain. Such people are called Rust, They always have a pet crab with them. The whole world of coding fears such crab owner.

Not too long ago, it was reported to the police station that the people of the rust cult killed a bunch of elderly men, an unusual thing, which police found was that these men had similar names.

  • C
  • C++

Looking at this chaos, police officers had no choice but to call for help, The Issue was that all the police men who were part of Python Cult or Web Cult (these guys often pet spide as they love web) were afraid to investigate futher and stop the chaos.

So, police had to hire someone who could compete with these ruthless crab owners.

But in the whole world of coding, there was no one to stand against the crab owners, except.....

People belonging to the Gophers Cult and Z+ Cult

Wait, wtf, looks like I went too deep into storytelling.

Introduction

Whatever, if you still didn't get what I meant by the story, then let me tell you what the moral of the story is.

I am learning GO, and taking part in the gopher cult

Now two questions arise
.

  • Why
  • Why not Zig (Z+ Cult)

And the answer is simple: To stop the chaos of rust, and I don't like the boring logo of Zig for some reason.

See some news that recently gained my attention:

  • Microsoft EDIT is back (And 100% made in Rust)

  • Crab Cult Strikes again and kills a cat, I meant Google makes a GitHub alternative named Jujutsu, which is better than GitHub, and also 100% made in Rust

  • Crab Cult went to the atomic level and used Tauri to fight Electron.

  • Zed, the Visual Studio Code killer, is also 100% made in Rust.

Man, I am so tired of the rust that I started to hate rust.

And another reason I hate rust is, I don't like crabs. I like adorable animals like Miniscript Mascot or Go Mascot.

But the issue is that no go developer is going to develop, making some good stuff.

So I thought I must fill the GO gap.

But I don't know GO.

So that's why today I introduce to you - GO 101

What is GO 101?

Here, I randomly make anything in GO. Without any help from LLM or any tutorial.

Only thing I can use is the GO Documentation and nothing and I have to do this for the next 30 Days to track the improvement.

Edit : I FORGOT TO TELL I CAN ALSO ACCESS MY COPY, WHERE I HAVE ALL GO SYNTAX WRITTEN (NOT CODE JUST SYNTAX LIKE HOW TO MAKE IF ELSE BLOCKS OR LOOP)

At the end of the day, we will give our code to LLM and Learn How to improve it.

Rules
  • If somehow break the streak before 30 days. I have to make 3 projects in a single day. 1 For the day I am making, 1 for the day I broke my streak, and 1 as a penalty. The more I break the streak more penalties increase.

  • I can create multiple projects in a single day, but those won't count; they would only count when I break my streak.

  • Streak cannot be broken on purpose

  • If I don't follow the rules either I have to delete the most viewed video or blog post

Day 1

I had no idea what to do, just some documentation (Which I didn't even use once today) and my copy.

I thought a calculator would be perfect for Day 1.

My plan was would take input from the user and store it into 3 variables.

  • Number1
  • Operator
  • Number2

Then, according to the inputted operator, I would use a switch statement and print the output.

And here is what I coded.

package main

import (
    "fmt"
)

func main() {
    var Number1 int
    var Operator string
    var Number2 int
    fmt.Print("Enter the first number: ")
    fmt.Scan(&Number1)
    fmt.Print("Enter the operator: ")
    fmt.Scan(&Operator)
    fmt.Print("Enter the second number: ")
    fmt.Scan(&Number2)
    switch Operator {
    case "+":
        fmt.Print("Result: ")
        fmt.Print(Number1 + Number2)
    case "-":
        fmt.Print("Result: ")
        fmt.Print(Number1 - Number2)
    case "*":
        fmt.Print("Result: ")
        fmt.Print(Number1 * Number2)
    case "%":
        fmt.Print("ResuResult: lt")
        fmt.Print(Number1 % Number2)
    case "/":
        fmt.Print("Result: ")
        fmt.Print(Number1 / Number2)
    default:
        fmt.Println("Invalid Input Make Sure that First and Second digit are integer and operator is one of: ")
        fmt.Println("+ (add)")
        fmt.Println("- (subtract)")
        fmt.Println("/ (divide)")
        fmt.Println("* (multiply)")
        fmt.Println("% (remainder)")

    }

}
Enter fullscreen mode Exit fullscreen mode

What's good in this code (According to ChatGpt)

  • ✅ Clean use of fmt.Scan for input – no weirdness or unnecessary complexity.

  • ✅ switch for operator handling — clean, readable, idiomatic Go.

  • ✅ You handled the "default" case well and gave user feedback. Nice UX touch!

  • ✅ Works well for basic integer operations.

What's bad in this code (According to me)

  • Doesn't Support Floats (I forgot about that)

  • Very very congested

  • Could have been better.

What's bad in this code (ChatGPT)

  • Input validation is missing.

If I enter "cat" as a number, your program will say “hmm yeah, looks legit” and panic later. You can fix this by scanning into strings first and using strconv.Atoi.

  • Division by zero risk!

If Number2 is 0 and the operator is /, 💥 boom. You should add a check to avoid dividing by zero.

  • Case typo:

fmt.Print("ResuResult: lt")

Bro, did the % operator hurt you? 😂 Just a little typo — easy fix.

  • Could be DRY-er.

You're repeating fmt.Print("Result: ") for each case. You could make a helper function like printResult(x int) or even handle that at the end.

Conclusion (By ChatGPT)

7.5 / 10

That’s a solid first Go project. You showed you understand types, inputs, conditionals, and Go’s basic syntax — and you did it solo. Now imagine how far you’ll go if you keep stacking projects like this 🔥

My thoughts

There is nothing worse than getting roasted by AI.

The worst thing I did in this code and didn't even notice was that typo.

I feel ashamed but I don't care

Here is the fixed version by AI if someone wants

Fixed Version

package main

import (
    "fmt"
)

func main() {
    var number1, number2 int
    var operator string

    fmt.Print("Enter the first number: ")
    fmt.Scan(&number1)

    fmt.Print("Enter the operator (+, -, *, /, %): ")
    fmt.Scan(&operator)

    fmt.Print("Enter the second number: ")
    fmt.Scan(&number2)

    fmt.Print("Result: ")
    switch operator {
    case "+":
        fmt.Println(number1 + number2)
    case "-":
        fmt.Println(number1 - number2)
    case "*":
        fmt.Println(number1 * number2)
    case "/":
        if number2 == 0 {
            fmt.Println("Error: Cannot divide by zero.")
        } else {
            fmt.Println(number1 / number2)
        }
    case "%":
        if number2 == 0 {
            fmt.Println("Error: Cannot modulo by zero.")
        } else {
            fmt.Println(number1 % number2)
        }
    default:
        fmt.Println("Invalid operator. Use one of +, -, *, /, %")
    }
}

Enter fullscreen mode Exit fullscreen mode

Outro

Coming Soon:

  • GO 101 : Day 2 (Tommorow)
  • Learn By Code 1.3 - Click ASAP
  • Learn By Code 2.1 - Click ASAP
  • Ebiten - Creating Games with GO
  • Love2D - Creating Games with Lua
  • Pygame - Creating games with Python
  • "fmt" Package in GO

Recommended Post:
Mini Micro

GO

Conceptual

Developer Essential

Learn By Code and Code Review

Comments 0 total

    Add comment