Skip to content

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.

Notifications You must be signed in to change notification settings

MisaghMomeniB/Number-Guessing-Game-Go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 

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

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages