Initial commit: Go project with greet function and CLI

This commit is contained in:
Gabriel Radureau
2026-04-03 12:20:55 +02:00
commit 3efc1992d5
7 changed files with 201 additions and 0 deletions

30
.gitignore vendored Normal file
View File

@@ -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

55
AGENTS.md Normal file
View File

@@ -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!"

62
README.md Normal file
View File

@@ -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

17
cmd/greet/main.go Normal file
View File

@@ -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))
}

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module DanceLessonsCoach
go 1.26.1

10
pkg/greet/greet.go Normal file
View File

@@ -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 + "!"
}

24
pkg/greet/greet_test.go Normal file
View File

@@ -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)
}
})
}
}