Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/openapphub/golang-basic-demos

Golang Basic Demos
https://github.com/openapphub/golang-basic-demos

golang-basic-demos hello-world

Last synced: 2 days ago
JSON representation

Golang Basic Demos

Awesome Lists containing this project

README

        

# Golang Basic Demos

This repository contains multiple basic Golang example programs suitable for beginners to learn and practice. Each example covers different aspects of Golang, from a simple "Hello World" to concurrent programming and web servers. Through these examples, you can gradually master the core concepts and syntax of Golang.

## Table of Contents

1. [Hello World](#hello-world)
2. [FizzBuzz](#fizzbuzz)
3. [Number Guessing Game](#number-guessing-game)
4. [Fibonacci Sequence](#fibonacci-sequence)
5. [Concurrent Calculation](#concurrent-calculation)
6. [Web Server](#web-server)
7. [JSON Handling](#json-handling)
8. [File I/O](#file-io)

## Example Descriptions

### Hello World
The most basic introductory program, outputting "Hello, World!".

### FizzBuzz
A classic programming exercise, printing numbers from 1 to 100. For multiples of 3, print "Fizz"; for multiples of 5, print "Buzz"; for numbers that are multiples of both 3 and 5, print "FizzBuzz".

### Number Guessing Game
A simple number guessing game where the program randomly generates a number between 1 and 100. The user inputs guesses, and the program hints whether the guess is too high or too low until the correct number is guessed.

### Fibonacci Sequence
Generates the first N terms of the Fibonacci sequence.

### Concurrent Calculation
Uses Goroutines and Channels for concurrent calculation, such as summing numbers from 1 to 100.

### Web Server
Creates a simple HTTP server that returns "Hello, World!".

### JSON Handling
Reads JSON data and parses it into a struct.

### File I/O
Reads the content of a file and writes it to another file.

## How to Run

1. Clone the repository to your local machine:
```bash
git clone https://github.com/openapphub/golang-basic-demos.git
Navigate to the repository directory:
```
2. Navigate to the repository directory:
```
cd golang-basic-demos
```

3. Navigate to the respective example directory, for example hello-world:
```
cd hello-world
```

4. Run the example program:
```
go run main.go
```

## Contributing
Feel free to submit issues and improvement suggestions! If you have new example programs or ideas to improve existing ones, please submit a Pull Request.