- Tasks must be named
.zed/tasks.json(NOT.jsonc) - Zed's JSON parser accepts JSONC syntax (comments with
//) - No trailing commas allowed - this was the key issue!
[
{
"label": "Task Name",
"command": "command to run",
"cwd": "${ZED_WORKTREE_ROOT}",
"tags": ["category"]
}
]- Open with
cmd-shift-p→task: spawn(oropt-shift-t) - Rerun last task:
task: rerun(oropt-t) - Tasks are filtered by available variables
Instead of complicated HTTP servers and curl commands, the Unix way is simpler:
go run main.go > output.giffunc main() {
lissajous(os.Stdout) // Write to standard output
}os.Stdout= standard output stream- Shell's
>operator redirects it to a file - Without
>, binary data appears as garbage in terminal
✅ Flexible: Users decide where output goes
./program > file.gif # Save to file
./program | display - # Pipe to image viewer
./program > /dev/null # Discard output✅ Simple: No need for file handling in code ✅ Composable: Works with other Unix tools
- Compiles Go source code to machine code
- Links all dependencies
- Creates a standalone executable
- No Go runtime needed to run it
go build -o bin/lissajous main.goResult:
- Input:
main.go(~4KB source code) - Output:
bin/lissajous(~2.4MB executable) - Format: Mach-O 64-bit executable arm64 (for Apple Silicon)
- ⚡ Fast startup - no compilation at runtime
- 📦 Portable - copy to another machine and it works
- 🚀 No dependencies - users don't need Go installed
- 💨 Native performance - runs at full CPU speed
# Instead of:
go run main.go > output.gif
# You can:
./bin/lissajous > output.gifGo can build binaries for different platforms from a single machine:
# For Linux
GOOS=linux GOARCH=amd64 go build -o bin/lissajous-linux main.go
# For Windows
GOOS=windows GOARCH=amd64 go build -o bin/lissajous.exe main.go
# For macOS Intel
GOOS=darwin GOARCH=amd64 go build -o bin/lissajous-mac-intel main.go
# For macOS ARM (M1/M2/M3)
GOOS=darwin GOARCH=arm64 go build -o bin/lissajous-mac-arm main.goThis means you can distribute your program to users on any platform! 🎉
Instead of deleting old code, comment it out with explanations:
// Uncomment below to run as HTTP server:
// handler := func(w http.ResponseWriter, r *http.Request){
// lissajous(w)
// }
// http.HandleFunc("/", handler)
// log.Fatal(http.ListenAndServe("localhost:8000", nil))
// Output GIF to stdout (use with: go run main.go > output.gif)
lissajous(os.Stdout)Why?
- Easy to switch between modes
- Preserves working code
- Documents alternative approaches
- Helps future you remember options
- Keep it simple -
go run main.go > output.gifbeats complex HTTP + curl - Write to stdout - Let the shell handle redirection
- Binaries are powerful - Distribute standalone executables
- Comment, don't delete - Preserve alternative implementations
- Unix philosophy - Do one thing well, compose with others
go_pp/
├── .zed/
│ └── tasks.json # Zed task definitions
├── shape/
│ └── main.go # Shape animations server
├── main.go # Lissajous GIF generator
├── go.mod # Go module file
└── *.gif # Generated animations
# Generate GIF
go run main.go > output.gif
# Build binary
go build -o bin/lissajous main.go
# Run binary
./bin/lissajous > output.gif
# Format and vet code
go fmt ./... && go vet ./...
# Open GIF (macOS)
open output.gifLast updated: 2024