From 46a4c919614c3bcdba993706a7e4402060955378 Mon Sep 17 00:00:00 2001 From: liulingfei-1 Date: Sun, 10 Aug 2025 00:59:58 +0800 Subject: [PATCH 1/4] docs: enhance readme --- README.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d7d526e..9d18a3f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,60 @@ -# Hello-World- -My first repository in Github +# Hello World Collection + +A curated set of minimal programs that print **"Hello, World"** in a variety of programming languages. This repository is useful for quick syntax lookups or verifying that a toolchain is configured correctly. + +## Supported languages + +- **C** – `HelloWorld.c` +- **C#** – `HelloWorld.cs` +- **C++** – `Helloworld.cpp` +- **Java** – `HelloWorld.java` +- **Python** – `HelloWorld.py` +- **Visual Basic** – `HelloWorld.vb` +- **TypeScript** – `Helloworld.ts` + +## Running the examples +Each example is a single file that prints `Hello, World!` to standard output. Compile or interpret the file using the toolchain for that language: + +### C +```bash +gcc HelloWorld.c -o hello && ./hello +``` + +### C# +```bash +csc HelloWorld.cs && ./HelloWorld.exe +``` + +### C++ +```bash +g++ Helloworld.cpp -o hello && ./hello +``` + +### Java +```bash +javac HelloWorld.java && java HelloWorld +``` + +### Python +```bash +python HelloWorld.py +``` + +### Visual Basic +```bash +vbnc HelloWorld.vb && mono HelloWorld.exe +``` + +### TypeScript +```bash +tsc Helloworld.ts && node Helloworld.js +``` + +## Contributing + +Feel free to submit pull requests that add new languages or improve existing examples. + +## License + +This project is licensed under the [MIT License](LICENSE). + From b89c2f785acfdbcf40eff1ce9e9b4a1a309a22b4 Mon Sep 17 00:00:00 2001 From: liulingfei-1 Date: Sun, 10 Aug 2025 01:07:44 +0800 Subject: [PATCH 2/4] Ignore pytest cache directory --- .gitignore | 5 +++++ HelloWorld.java | 7 ++++--- HelloWorld.py | 4 +++- HelloWorld.vb | 3 ++- README.md | 2 +- tests/test_hello.py | 8 ++++++++ 6 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 tests/test_hello.py diff --git a/.gitignore b/.gitignore index 259148f..ac3dfc3 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,8 @@ *.exe *.out *.app + +# Python cache +__pycache__/ +*.pyc +.pytest_cache/ diff --git a/HelloWorld.java b/HelloWorld.java index 5f1720f..31ee826 100644 --- a/HelloWorld.java +++ b/HelloWorld.java @@ -1,5 +1,6 @@ -public class Helloworld{ - public static void main(String[] args){ - System.out.println("Hello,World!"); +public class HelloWorld { + public static void main(String[] args) { + // Print the traditional greeting. + System.out.println("Hello, World!"); } } diff --git a/HelloWorld.py b/HelloWorld.py index 3568c85..1cdd10b 100644 --- a/HelloWorld.py +++ b/HelloWorld.py @@ -1,2 +1,4 @@ #!/usr/bin/python3 -print("Hello,world!") +"""Simple Hello World script.""" + +print("Hello, World!") diff --git a/HelloWorld.vb b/HelloWorld.vb index 0122069..effb808 100644 --- a/HelloWorld.vb +++ b/HelloWorld.vb @@ -2,6 +2,7 @@ Imports System Module HelloWorld Sub Main(args As String()) - Console.WriteLine("Hello World!") + ' Display the greeting. + Console.WriteLine("Hello, World!") End Sub End Module diff --git a/README.md b/README.md index 9d18a3f..476a8ca 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ javac HelloWorld.java && java HelloWorld ### Python ```bash -python HelloWorld.py +python3 HelloWorld.py ``` ### Visual Basic diff --git a/tests/test_hello.py b/tests/test_hello.py new file mode 100644 index 0000000..9ac295a --- /dev/null +++ b/tests/test_hello.py @@ -0,0 +1,8 @@ +import subprocess +import sys +from pathlib import Path + +def test_python_hello_output(): + script = Path(__file__).resolve().parents[1] / 'HelloWorld.py' + result = subprocess.run([sys.executable, str(script)], capture_output=True, text=True, check=True) + assert result.stdout.strip() == 'Hello, World!' From dbb40d4f455319e10fe7455bfa1656034939ad91 Mon Sep 17 00:00:00 2001 From: liulingfei-1 Date: Sun, 10 Aug 2025 01:12:52 +0800 Subject: [PATCH 3/4] Translate README to Chinese --- README.md | 2 ++ README.zh.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 README.zh.md diff --git a/README.md b/README.md index 476a8ca..328b844 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Hello World Collection +[English](README.md) | [中文](README.zh.md) + A curated set of minimal programs that print **"Hello, World"** in a variety of programming languages. This repository is useful for quick syntax lookups or verifying that a toolchain is configured correctly. ## Supported languages diff --git a/README.zh.md b/README.zh.md new file mode 100644 index 0000000..9193fc8 --- /dev/null +++ b/README.zh.md @@ -0,0 +1,63 @@ +# Hello World 集合 + +[English](README.md) | 中文 + +一组经过精心整理的最小程序集合,演示如何在多种编程语言中输出 **"Hello, World"**。此仓库可用于快速查阅语法或验证工具链是否配置正确。 + +## 支持的语言 + +- **C** – `HelloWorld.c` +- **C#** – `HelloWorld.cs` +- **C++** – `Helloworld.cpp` +- **Java** – `HelloWorld.java` +- **Python** – `HelloWorld.py` +- **Visual Basic** – `HelloWorld.vb` +- **TypeScript** – `Helloworld.ts` + +## 运行示例 + +每个示例都是一个输出 `Hello, World!` 到标准输出的单文件程序。根据所使用的语言,使用其相应的工具链来编译或解释: + +### C +```bash +gcc HelloWorld.c -o hello && ./hello +``` + +### C# +```bash +csc HelloWorld.cs && ./HelloWorld.exe +``` + +### C++ +```bash +g++ Helloworld.cpp -o hello && ./hello +``` + +### Java +```bash +javac HelloWorld.java && java HelloWorld +``` + +### Python +```bash +python3 HelloWorld.py +``` + +### Visual Basic +```bash +vbnc HelloWorld.vb && mono HelloWorld.exe +``` + +### TypeScript +```bash +tsc Helloworld.ts && node Helloworld.js +``` + +## 贡献 + +欢迎提交 Pull Request 以添加新语言或改进现有示例。 + +## 许可证 + +本项目使用 [MIT 许可证](LICENSE)。 + From 53a5a05056cb4f21ddd799325bf66bc6f298e6aa Mon Sep 17 00:00:00 2001 From: liulingfei-1 Date: Sun, 10 Aug 2025 01:17:01 +0800 Subject: [PATCH 4/4] Add Hello World examples in Go, Ruby, and Rust --- HelloWorld.go | 5 +++++ HelloWorld.rb | 1 + HelloWorld.rs | 3 +++ README.md | 18 ++++++++++++++++++ README.zh.md | 18 ++++++++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 HelloWorld.go create mode 100644 HelloWorld.rb create mode 100644 HelloWorld.rs diff --git a/HelloWorld.go b/HelloWorld.go new file mode 100644 index 0000000..b488eb8 --- /dev/null +++ b/HelloWorld.go @@ -0,0 +1,5 @@ +package main +import "fmt" +func main() { + fmt.Println("Hello, World!") +} diff --git a/HelloWorld.rb b/HelloWorld.rb new file mode 100644 index 0000000..db1ddb0 --- /dev/null +++ b/HelloWorld.rb @@ -0,0 +1 @@ +puts 'Hello, World!' diff --git a/HelloWorld.rs b/HelloWorld.rs new file mode 100644 index 0000000..0672e51 --- /dev/null +++ b/HelloWorld.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, World!"); +} diff --git a/README.md b/README.md index 328b844..ce5cd22 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ A curated set of minimal programs that print **"Hello, World"** in a variety of - **Python** – `HelloWorld.py` - **Visual Basic** – `HelloWorld.vb` - **TypeScript** – `Helloworld.ts` +- **Go** – `HelloWorld.go` +- **Ruby** – `HelloWorld.rb` +- **Rust** – `HelloWorld.rs` ## Running the examples Each example is a single file that prints `Hello, World!` to standard output. Compile or interpret the file using the toolchain for that language: @@ -52,6 +55,21 @@ vbnc HelloWorld.vb && mono HelloWorld.exe tsc Helloworld.ts && node Helloworld.js ``` +### Go +```bash +go run HelloWorld.go +``` + +### Ruby +```bash +ruby HelloWorld.rb +``` + +### Rust +```bash +rustc HelloWorld.rs && ./HelloWorld +``` + ## Contributing Feel free to submit pull requests that add new languages or improve existing examples. diff --git a/README.zh.md b/README.zh.md index 9193fc8..f8f2ea0 100644 --- a/README.zh.md +++ b/README.zh.md @@ -13,6 +13,9 @@ - **Python** – `HelloWorld.py` - **Visual Basic** – `HelloWorld.vb` - **TypeScript** – `Helloworld.ts` +- **Go** – `HelloWorld.go` +- **Ruby** – `HelloWorld.rb` +- **Rust** – `HelloWorld.rs` ## 运行示例 @@ -53,6 +56,21 @@ vbnc HelloWorld.vb && mono HelloWorld.exe tsc Helloworld.ts && node Helloworld.js ``` +### Go +```bash +go run HelloWorld.go +``` + +### Ruby +```bash +ruby HelloWorld.rb +``` + +### Rust +```bash +rustc HelloWorld.rs && ./HelloWorld +``` + ## 贡献 欢迎提交 Pull Request 以添加新语言或改进现有示例。