An open API service indexing awesome lists of open source software.

https://github.com/misaghmomenib/number-guessing-game-go

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.
https://github.com/misaghmomenib/number-guessing-game-go

git golang number-guessing-game open-source

Last synced: 2 months ago
JSON representation

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.

Awesome Lists containing this project

README

          

# 🎯 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](#overview)
2. [Features](#features)
3. [Tech Stack & Requirements](#tech-stack--requirements)
4. [Installation & Build](#installation--build)
5. [Usage Examples](#usage-examples)
6. [Code Structure](#code-structure)
7. [Extendability Ideas](#extendability-ideas)
8. [Contributing](#contributing)
9. [License](#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:

```bash
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:

```bash
go run main.go
```

---

## πŸš€ Usage Examples

Run the game:

```bash
./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.