Story Continues
(You would not understand the story if you haven't read GO 101: Day 1. Use the keywords I provided below to help you know the story.)
Keyword
- Crab Cult = Rust users (Taking over the world)
- Gophers = GO user (Volunteered To Stop Crab Cult)
- Z+ Cult = Zig Users (Volunteered To Stop Crab Cult)
- Elderly men = C and C++ (Murdered by Crab Cult)
- Police Officers = Python Users and Web Developers (Afraid Crab Cult)
- Typers++ = TypeScript Users
- Coffee Lovers = JavaScript Users (Java means "a beverage consisting of an infusion of ground coffee beans")
- Spiders = Web Developers -Soft Cult = Software Developers
Context
Crab Cult is starting to become dangerous day by day. There is no one to stop them. Police officers are afraid to stand against the power of Underworld Gangsters (low-level languages), and those who could have defeated the Crab Cult have already been murdered by the Crab Cult.
At the end, officers had no choice but to call for help, but everyone was afraid of the Crab Cult. In the whole world, no one was ready to stand against them except
Gophers
Z++ Cult
What Next?
Chaos was going on in the crab cult headquarters. Some were shouting, some were regretting, and some were planning for revenge.
The reason for this chaos was a single news item.
Typers get protection from Gophers
Translation: Typescript Compiler rewritten in GO
The leader of the crab cult was very shocked by this news, as their next target after the legendary elder men were Typers and Coffee Lovers.
Even the general chief of Crab Cult, named Taur, has already started to take over the general chief of Spiders and Soft Cult, called Electron.
The leader of the Crab Cult knew that if the Typers were getting help from Gophers, it would be hard to eliminate the spiders and the soft cult. He knew Gophers are thinking steps ahead of them.
TO BE CONTINUED.....
Before We Move On
Guys, all this story is just for humor, I don't hate Rust, so don't get offended.
What is GO 101
Here, I randomly make anything in GO. Without any help from LLM or any tutorial.
The only thing I can use is the GO Documentation for syntax only and nothing, and I have to do this for the next 30 Days to track the improvement.
Day 2
While I was scrolling through. GO documentation, I found out how you obtain a random integer in GO.
So I decided this would be the best project for Day 2
Project Idea: Guessing Game
This was my idea:
- I would make a program that generates a random integer between 1 to 50
- Then I would ask the user to input what they guess the integer is.
- If the guessed integer is more than the random integer. I would print too high.
- If it is less than, I would print too low.
- If it is the same as a random integer, then they win
- If they enter a non-integer value, I would give feedback to enter an integer
- They will get 5 chances to guess the correct integer
Implementation
Pseduo Code
- I would use
Scanln
to the same user input in a variable calledGuessed_number
- Using
rand.Intn(50)
, I would store the random integer into another variable - Then I will use
for loop
to repeat theif-else block
,input-taking process
, 5 times - The
if-else
block will give feedback to the user like: Too High, Too Low, etc
Real Code
package main
import (
"fmt"
"math/rand"
)
func main() {
random_number := rand.Intn(50)
var Guessed_number int
fmt.Println("This project is made in GO 101 Day 2")
fmt.Println("Random Digit is between 0-50")
fmt.Println("This is a random number guessing.")
fmt.Println("You have 5 chances lets see you get it correct or not")
for x := 0; x <= 4; x++ {
fmt.Print("Enter You Guess: ")
fmt.Scanln(&Guessed_number)
if Guessed_number > random_number {
fmt.Println("Too High")
} else if Guessed_number < random_number {
fmt.Println("Too Low")
} else if Guessed_number == random_number {
fmt.Printf("Yes You Guessed it right %d was the correct number.", random_number)
} else {
fmt.Println("Enter a valid integer")
}
}
}
It's Your Turn
Previously (Day 1), I had used LLM to find mistakes in my program, which I have clearly stated in my blog by providing what I wrote and what I should have written according to LLM. Many people didn't like it, so this time I leave this up to you. Go comment below on what you think is the issue with this program. How can it be improved?
What I think
Currently, as I can't even use LLM or any tutorial, I don't know how to do it, but I am sure this is a way in which I can check the data type of user-input value.
I tried different ways to implement it yesterday, but none of them worked, and I took less help from the documentation (Mostly to know the syntax). I don't know how to implement it.
If someone in the comment section could help me with that, it would be very helpful.
Outro
Recommended Post:
Mini Micro
GO
Conceptual
Developer Essential
Learn By Code and Code Review