Skip to content

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

🎯 Number Guessing Game (Go)

A fun and interactive CLI number‑guessing game written in Go. A classic project to practice Go basics, randomization, input handling, and simple game design—all in your terminal.


📋 Table of Contents

  1. Overview
  2. Features
  3. Tech Stack & Requirements
  4. Installation & Build
  5. Usage Examples
  6. Code Structure
  7. Extendability Ideas
  8. Contributing
  9. License

💡 Overview

This terminal-based game picks a random number and challenges you to guess it with feedback after each try. It demonstrates Go fundamentals like package structure, random number generation, input/output routines, and loop control—perfect for beginners and educators.


✅ Features

  • 🎲 Random number generation between 1 and 100
  • 🔁 Loop for continuous guessing until correct
  • 📊 Feedback hints: "too high" or "too low"
  • 📈 Counter for tracking attempts
  • 👋 Replay option after a win

🛠️ Tech Stack & Requirements

  • Go 1.18+ with module support
  • Uses only Go standard libraries (fmt, bufio, os, math/rand, time)

⚙️ Installation & Build

Clone and build:

git clone https://github.com/MisaghMomeniB/Number-Guessing-Game-Go.git
cd Number-Guessing-Game-Go
go build -o guess-game main.go

Alternatively, run directly:

go run main.go

🚀 Usage Examples

Run the game:

./guess-game

Sample session:

Welcome to Number Guessing Game!
I'm thinking of a number between 1 and 100.
Enter your guess:
> 50
Too high!
Attempts: 1
> 37
Too low!
Attempts: 2
...
> 42
🎉 You guessed it in 7 attempts!
Play again? (y/n):

📁 Code Structure

Number-Guessing-Game-Go/
└── main.go         # Game logic and I/O loop
  • Generates a random target (rand.Intn(100) + 1)
  • Reads input using bufio.Reader and parses integers
  • Provides feedback and keeps guessing until correct
  • Prompts to play again or exit

💡 Extendability Ideas

  • 🌟 Add difficulty levels (e.g., easy: 1–10, hard: 1–1000)
  • ⏱️ Add timer to track playtime
  • 🗃️ Maintain high-scores or best performance logs
  • 🎨 Add ASCII art or colorized output
  • 📦 Package as a module with flags (e.g., --max=500)

🤝 Contributing

Contributions welcome! Suggestions include:

  1. Fork the repo
  2. Create a feature/... branch
  3. Write clean, commented code
  4. Submit a Pull Request with changes

📄 License

Released under the MIT License — see LICENSE file for details.

About

A Fun and Engaging Number Guessing Game Built With Go. Challenge Yourself or Others to Guess the Correct Number Within a Set Range, With Feedback Provided After Each Guess to Guide You Towards the Solution.

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages