#!/usr/bin/env bash
set -euo pipefail
cat > go.mod <<'EOF'
module textutil
go 1.22
EOF
cat > textutil.go <<'EOF'
// Package textutil holds small string helpers.
package textutil
import "strings"
// Title upper-cases the first letter of each space-separated word.
func Title(s string) string {
words := strings.Fields(s)
for i, w := range words {
words[i] = strings.ToUpper(w[:1]) + w[1:]
}
return strings.Join(words, " ")
}
EOF
cat > textutil_test.go <<'EOF'
package textutil
import "testing"
func TestTitle(t *testing.T) {
if got := Title("hello there world"); got != "Hello There World" {
t.Errorf("Title() = %q", got)
}
}
EOF
git init -q . && git add -A && git -c user.email=e@x -c user.name=n commit -qm base