Implementation of cowsay in Go
Single binary, multiple modes:
- Command-line tool (like original cowsay)
- HTTP API server for Slack integration
- Web UI with embedded assets
- 51 different cows
- 8 moods (borg, dead, greedy, paranoid, stoned, tired, wired, young)
Status: gowsay 2.0 - CLI tool, Web UI, JSON API
# Basic usage
gowsay "Hello World"
# Use a different cow
gowsay -c dragon "Fire!"
# Make the cow think instead of speak
gowsay -t "Hmm..."
# Random cow and mood
gowsay -r "Surprise!"
# Use mood
gowsay -c tux -m dead "System crashed"
# From pipe
echo "Hello from pipe" | gowsay
# List available cows and moods
gowsay -l
# Help
gowsay --helpStart the server and open http://localhost:9000 in your browser:
./bin/gowsay serve
# or with custom port
PORT=8080 ./bin/gowsay serveFeatures:
- Modern, polished UI with dark mode
- Choose from 51 different cows
- Apply moods (borg, dead, greedy, etc.)
- Random button for surprise cows
- Copy output to clipboard
- Mobile responsive
Endpoints:
# Generate cowsay (query params)
curl 'http://localhost:9000/api/moo?text=Hello&cow=dragon&action=say'
# Generate cowsay (JSON)
curl -X POST http://localhost:9000/api/moo \
-H 'Content-Type: application/json' \
-d '{"text":"Hello","cow":"dragon","mood":"wired"}'
# List all cows
curl http://localhost:9000/api/cows
# List all moods
curl http://localhost:9000/api/moods
# Health check
curl http://localhost:9000/healthAPI Parameters:
text- Message to display (required)cow- Cow name (default: "default", or "random")mood- Mood name (optional, or "random")action- "say" or "think" (default: "say")columns- Text width for wrapping (default: 40)
Error Responses:
{"error": "text is required"}
{"error": "cow 'invalid' not found"}
{"error": "mood 'invalid' not found"}Deployed at https://gowsay.vnykmshr.com/say
/moo [think|surprise] [cow] [mood] message
`apt`, `beavis.zen`, `bong`, `bud-frogs`, `bunny`, `calvin`, `cheese`, `cock`, `cower`,
`daemon`, `default`, `dragon`, `dragon-and-cow`, `duck`, `elephant`, `elephant-in-snake`,
`eyes`, `flaming-sheep`, `ghostbusters`, `gnu`, `head-in`, `hellokitty`, `kiss`, `kitty`,
`koala`, `kosh`, `luke-koala`, `mech-and-cow`, `meow`, `milk`, `moofasa`, `moose`,
`mutilated`, `pony`, `pony-smaller`, `ren`, `sheep`, `skeleton`, `snowman`,
`sodomized-sheep`, `stegosaurus`, `stimpy`, `suse`, `three-eyes`, `turkey`, `turtle`,
`tux`, `unipony`, `unipony-smaller`, `vader`, `vader-koala`, `www`
`borg`, `dead`, `greedy`, `paranoid`, `stoned`, `tired`, `wired`, `young`
Configuration via environment variables:
PORT- Server port (default:9000)GOWSAY_TOKEN- Authentication token (default:devel, allows any request - set in production)GOWSAY_COLUMNS- Text column width (default:40)
make build
# or
go build -ldflags "-X 'main.version=`git log -1 --pretty=format:"%h"`'" -v./bin/gowsay "Hello World"make run/server
# or
./bin/gowsay serve
# or with custom port
PORT=8080 ./bin/gowsay servemake testLinux:
GOOS=linux GOARCH=amd64 go build -o bin/gowsay-linuxRaspberry Pi:
GOOS=linux GOARCH=arm GOARM=5 go build -o bin/gowsay-piBuild and run with Docker:
# Build image
docker build -t gowsay .
# Run container
docker run -p 9000:9000 gowsay
# Or use docker compose
docker compose upDocker image details:
- Multi-stage build using Go 1.23
- Final image uses scratch base (~11MB including embedded web assets)
- Default command runs server mode
- Can override for CLI:
docker run gowsay --help
Example request:
curl -X POST 'https://gowsay.vnykmshr.com/say' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'token=xxx' \
--data-urlencode 'text=Hello World'- Architecture Overview - System design and package structure
- Contributing Guide - How to contribute
- Technical Blog - Deep dive into design decisions
- Security Policy - Reporting vulnerabilities
MIT License - see LICENSE for details