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.
- Host: GitHub
- URL: https://github.com/misaghmomenib/number-guessing-game-go
- Owner: MisaghMomeniB
- Created: 2024-12-25T17:56:52.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-06-13T20:10:06.000Z (5 months ago)
- Last Synced: 2025-08-22T10:47:50.163Z (3 months ago)
- Topics: git, golang, number-guessing-game, open-source
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.