Commit 18c1cde
Changed files (4)
cmd/web/handlers.go
@@ -70,4 +70,4 @@ func isValidToken(token string) bool {
func about(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Server", "buylater.email")
w.Write([]byte("About - buylater.email helps you delay purchases and buy more intentionally"))
-}
\ No newline at end of file
+}
cmd/web/main.go
@@ -24,4 +24,4 @@ func main() {
// we use log.Fatal() to log the error and terminate the program.
err := http.ListenAndServe(":4000", mux)
log.Fatal(err)
-}
\ No newline at end of file
+}
docs/CLAUDE.md
@@ -37,36 +37,29 @@ This is a Go web application for "buylater.email" - an email-based delayed grati
## Development Commands
-### Running the Application
-```bash
-go run cmd/web/*.go
-```
-The server starts on port 4000.
-
-### Building the Application
-```bash
-go build ./cmd/web
-```
-
-### Testing
-```bash
-go test ./...
-```
-
-### Code Formatting
-```bash
-go fmt ./...
-```
+**Makefile Available**: Use `make help` to see all available targets.
-### Code Linting/Vetting
+### Quick Commands (via Makefile)
```bash
-go vet ./...
+make run # Start development server
+make build # Build application binary
+make test # Run tests
+make fmt # Format code
+make vet # Vet code
+make check # Run fmt, vet, and test
+make clean # Remove binaries
+make tidy # Clean up dependencies
```
-### Module Management
+### Direct Go Commands
```bash
-go mod tidy # Clean up dependencies
-go mod download # Download dependencies
+go run cmd/web/*.go # Run application (port 4000)
+go build ./cmd/web # Build application
+go test ./... # Run tests
+go fmt ./... # Format code
+go vet ./... # Vet code
+go mod tidy # Clean up dependencies
+go mod download # Download dependencies
```
## Architecture
Makefile
@@ -0,0 +1,72 @@
+# Makefile for buylater.email project
+.PHONY: build run test fmt vet clean help
+
+# Variables
+BINARY_NAME=buylater
+BINARY_PATH=./cmd/web
+BUILD_DIR=./bin
+
+# Default target
+all: build
+
+# Build the application
+build:
+ @echo "Building $(BINARY_NAME)..."
+ @mkdir -p $(BUILD_DIR)
+ @go build -o $(BUILD_DIR)/$(BINARY_NAME) $(BINARY_PATH)
+ @echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)"
+
+# Run the application for development
+run:
+ @echo "Starting development server..."
+ @go run $(BINARY_PATH)/*.go
+
+# Run tests
+test:
+ @echo "Running tests..."
+ @go test ./...
+
+# Format code
+fmt:
+ @echo "Formatting code..."
+ @go fmt ./...
+
+# Vet code for potential issues
+vet:
+ @echo "Vetting code..."
+ @go vet ./...
+
+# Clean up binaries
+clean:
+ @echo "Cleaning up..."
+ @rm -rf $(BUILD_DIR)
+ @rm -f $(BINARY_NAME)
+ @echo "Clean complete"
+
+# Tidy up dependencies
+tidy:
+ @echo "Tidying dependencies..."
+ @go mod tidy
+
+# Run all quality checks
+check: fmt vet test
+ @echo "All checks passed!"
+
+# Install development dependencies
+deps:
+ @echo "Downloading dependencies..."
+ @go mod download
+
+# Show help
+help:
+ @echo "Available targets:"
+ @echo " build - Build the application binary"
+ @echo " run - Run the application for development"
+ @echo " test - Run all tests"
+ @echo " fmt - Format all Go code"
+ @echo " vet - Run go vet on all code"
+ @echo " clean - Remove built binaries"
+ @echo " tidy - Clean up go.mod dependencies"
+ @echo " check - Run fmt, vet, and test"
+ @echo " deps - Download dependencies"
+ @echo " help - Show this help message"
\ No newline at end of file