From 3efc1992d5999a0f9d4b7c404f33813f26fbb4e0 Mon Sep 17 00:00:00 2001 From: Gabriel Radureau Date: Fri, 3 Apr 2026 12:20:55 +0200 Subject: [PATCH] Initial commit: Go project with greet function and CLI --- .gitignore | 30 ++++++++++++++++++++ AGENTS.md | 55 ++++++++++++++++++++++++++++++++++++ README.md | 62 +++++++++++++++++++++++++++++++++++++++++ cmd/greet/main.go | 17 +++++++++++ go.mod | 3 ++ pkg/greet/greet.go | 10 +++++++ pkg/greet/greet_test.go | 24 ++++++++++++++++ 7 files changed, 201 insertions(+) create mode 100644 .gitignore create mode 100644 AGENTS.md create mode 100644 README.md create mode 100644 cmd/greet/main.go create mode 100644 go.mod create mode 100644 pkg/greet/greet.go create mode 100644 pkg/greet/greet_test.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4d6764e --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool +*.out + +# Dependency directories +vendor/ + +# Go workspace file +go.work + +# IDE specific files +.idea/ +.vscode/ +*.swp + +# macOS specific files +.DS_Store + +# Environment files +.env +.env.local diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..7291266 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,55 @@ +# AGENTS.md + +This file documents the AI agents and tools used in this project. + +## Project Initialization + +- **Agent**: Mistral Vibe CLI Agent +- **Version**: devstral-2 +- **Date**: 2024-04-03 + +## Tasks Completed + +1. **Go Environment Setup** + - Verified Go installation + - Upgraded to Go 1.26.1 + - Verified version compatibility + +2. **Project Structure** + - Created idiomatic Go project layout + - Initialized go.mod with module name + - Set up cmd/ and pkg/ directories + +3. **Core Implementation** + - Implemented Greet() function in pkg/greet/ + - Added default behavior for empty names + - Created comprehensive unit tests + +4. **CLI Implementation** + - Built command-line interface in cmd/greet/ + - Implemented argument parsing + - Integrated with core library + +5. **Documentation** + - Created README.md with usage instructions + - Added .gitignore for standard exclusions + - Generated this AGENTS.md file + +## Tools Used + +- Go 1.26.1 +- Standard library only +- No external dependencies + +## Testing + +All tests pass: +```bash +go test ./... +``` + +## Verification + +CLI tested with: +- No arguments: `go run ./cmd/greet` → "Hello world!" +- With argument: `go run ./cmd/greet John` → "Hello John!" diff --git a/README.md b/README.md new file mode 100644 index 0000000..be31820 --- /dev/null +++ b/README.md @@ -0,0 +1,62 @@ +# DanceLessonsCoach + +A simple Go project demonstrating idiomatic package structure and CLI implementation. + +## Features + +- Greet function with default behavior +- Command-line interface +- Unit tests +- Go 1.26.1 compatible + +## Installation + +```bash +# Clone the repository +git clone https://github.com/yourusername/DanceLessonsCoach.git +cd DanceLessonsCoach + +# Build and run +go run ./cmd/greet +``` + +## Usage + +```bash +# Default greeting +go run ./cmd/greet +# Output: Hello world! + +# Custom greeting +go run ./cmd/greet John +# Output: Hello John! +``` + +## Testing + +```bash +# Run all tests +go test ./... + +# Run specific package tests +go test ./pkg/greet/ +``` + +## Project Structure + +``` +DanceLessonsCoach/ +├── cmd/ +│ └── greet/ +│ └── main.go # CLI entry point +├── pkg/ +│ └── greet/ +│ ├── greet.go # Core library +│ └── greet_test.go # Unit tests +├── go.mod # Go module definition +└── README.md # Project documentation +``` + +## License + +MIT diff --git a/cmd/greet/main.go b/cmd/greet/main.go new file mode 100644 index 0000000..9162540 --- /dev/null +++ b/cmd/greet/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "os" + + "DanceLessonsCoach/pkg/greet" +) + +func main() { + name := "" + if len(os.Args) > 1 { + name = os.Args[1] + } + + fmt.Println(greet.Greet(name)) +} \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d984988 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module DanceLessonsCoach + +go 1.26.1 diff --git a/pkg/greet/greet.go b/pkg/greet/greet.go new file mode 100644 index 0000000..2f48369 --- /dev/null +++ b/pkg/greet/greet.go @@ -0,0 +1,10 @@ +package greet + +// Greet returns a greeting message for the given name. +// If name is empty, it defaults to "world". +func Greet(name string) string { + if name == "" { + return "Hello world!" + } + return "Hello " + name + "!" +} \ No newline at end of file diff --git a/pkg/greet/greet_test.go b/pkg/greet/greet_test.go new file mode 100644 index 0000000..c67d1b7 --- /dev/null +++ b/pkg/greet/greet_test.go @@ -0,0 +1,24 @@ +package greet + +import "testing" + +func TestGreet(t *testing.T) { + tests := []struct { + name string + expected string + }{ + {"", "Hello world!"}, + {"John", "Hello John!"}, + {"Alice", "Hello Alice!"}, + {" ", "Hello !"}, // spaces are not considered empty + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := Greet(tt.name) + if result != tt.expected { + t.Errorf("Greet(%q) = %q, want %q", tt.name, result, tt.expected) + } + }) + } +} \ No newline at end of file