Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c9e512e
Update code generation templates and configurations
raphael Jul 12, 2025
1b25986
wip
raphael Jul 13, 2025
2f9492a
wip
raphael Jul 13, 2025
2d8b55f
Initial working implememtation for servers
raphael Jul 13, 2025
248519e
Introduce testutil
raphael Jul 14, 2025
9f341fc
Wip - tests pass
raphael Jul 14, 2025
648dfb5
* Convert OpenAPI to testutil
raphael Jul 14, 2025
72ec60d
Fully working server side
raphael Jul 16, 2025
55b67f2
save
raphael Jul 16, 2025
469c9f5
Working client
raphael Jul 16, 2025
7fcad75
Server example
raphael Jul 17, 2025
a0b5f96
Fix tests
raphael Jul 17, 2025
1558069
Save wip
raphael Jul 17, 2025
c28fbd3
CLI works
raphael Jul 17, 2025
cf9a20a
Fix bugs
raphael Jul 17, 2025
9ddca57
Initial websocket support for json-rpc server side
raphael Jul 21, 2025
9e42176
wip ws client
raphael Jul 22, 2025
f850586
wip
raphael Jul 27, 2025
8f21530
wip
raphael Jul 27, 2025
8fb2bce
wip
raphael Jul 27, 2025
3ef43f7
wip
raphael Jul 28, 2025
1a5b9d0
wip
raphael Jul 28, 2025
ae5b987
wip
raphael Jul 29, 2025
51567e9
Add JSON-RPC support with WebSocket handling
raphael Aug 1, 2025
134c40a
Enhance SSE client and templates with decoder support
raphael Aug 1, 2025
f9f4c12
Add JSON-RPC SSE support and integration tests
raphael Aug 2, 2025
0d3fcfc
Enhance JSON-RPC support with streaming and SSE improvements
raphael Aug 3, 2025
77bca4d
Refactor JSON-RPC SSE event handling and streamline notification/resp…
raphael Aug 4, 2025
9ad8303
Refactor JSON-RPC endpoint templates for improved streaming and error…
raphael Aug 4, 2025
e533330
Refactor JSON-RPC integration tests and enhance framework structure
raphael Aug 4, 2025
c42e1b7
Enhance JSON-RPC integration tests and framework functionality
raphael Aug 6, 2025
327795b
Remove deprecated DeepSource configuration and report coverage workfl…
raphael Aug 7, 2025
24557c7
Refactor validation tests and improve error handling in HTTP handlers
raphael Aug 7, 2025
70ad5f0
Fix build issues and Windows CI compatibility
raphael Aug 7, 2025
5ebc4d4
Fix integration tests to use locally compiled goa binary during CI
raphael Aug 7, 2025
e341c1b
Improve Windows CI compatibility for goa binary detection
raphael Aug 7, 2025
3de231d
Add comprehensive Windows CI debugging and robustness fixes
raphael Aug 7, 2025
71b9505
Clean up debug output and improve goa binary detection
raphael Aug 7, 2025
57f20b3
Comprehensive Windows CI fixes for goa binary handling
raphael Aug 7, 2025
e959d17
Fix template indentation issues causing Windows CI newline errors
raphael Aug 7, 2025
0d685a8
Revert to simpler binary building approach for integration tests
raphael Aug 7, 2025
b19b5fa
Fix SSE validation for mixed results and update integration tests
raphael Aug 7, 2025
791675f
Fix lint error: use errors.As instead of type assertion
raphael Aug 7, 2025
07cfde3
Update golden files for HTTP handler and SSE tests
raphael Aug 7, 2025
9c9104b
Fix payload decoding for WebSocket and streaming endpoints
raphael Aug 7, 2025
ebbcb6e
Update golden files after fixing payload decoding
raphael Aug 7, 2025
9387ccd
Trigger CI re-run to check for transient test failures
raphael Aug 7, 2025
1c019be
Handle broken pipe errors gracefully in WebSocket tests
raphael Aug 7, 2025
2fb46c5
Fix Windows line ending issues in tests
raphael Aug 8, 2025
3c6f645
Fix validation template syntax errors causing Windows CI failures
raphael Aug 8, 2025
77e8b6c
Normalize line endings in template reader for Windows compatibility
raphael Aug 8, 2025
995d218
Use testutil for WebSocket golden file tests to handle line endings
raphael Aug 8, 2025
01f53cd
fix(grpc/codegen): robust protoc plugin resolution across platforms
cursoragent Aug 8, 2025
5f2d215
Skip JSON-RPC integration tests on Windows
raphael Aug 8, 2025
ea797d1
Revert "fix(grpc/codegen): robust protoc plugin resolution across pla…
raphael Aug 8, 2025
21ad663
Enhance JSON-RPC documentation in README.md
raphael Aug 8, 2025
f8007ea
jsonrpc: expand transport docs (HTTP, SSE, WebSocket), clarify SSE Se…
raphael Aug 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 0 additions & 9 deletions .deepsource.toml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/report-coverage.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ cover.out

# MacOS cruft
**/.DS_Store

jsonrpc/integration_tests/tests/testdata/runs/*
29 changes: 26 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
version: "2"
linters:
enable:
- errorlint
- errcheck
- staticcheck
- errorlint # Better error handling patterns for Go 1.13+
- errcheck # Check for unchecked errors
- staticcheck # Advanced static analysis
- unparam # Detects unused parameters
- unused # Detects unused constants, variables, functions and types
- ineffassign # Detects ineffectual assignments
- bodyclose # Check HTTP response body is closed
- gocritic # Provides bug, performance and style diagnostics
- misspell # Check for misspelled words
- nakedret # Check naked returns in large functions
- prealloc # Suggest preallocating slices
- unconvert # Remove unnecessary type conversions
- whitespace # Check for unnecessary whitespace
- nilerr # Find code that returns nil even if error is not nil
- copyloopvar # Check for loop variable issues
- sqlclosecheck # Check sql.Rows and sql.Stmt are closed
- makezero # Find slice declarations with non-zero initial length
settings:
staticcheck:
checks:
- "-ST1001" # Dot imports are used intentionally in DSL
nakedret:
max-func-lines: 30
misspell:
ignore-rules:
- Statuser

135 changes: 135 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

<<<<<<< HEAD
## About This Project

Goa is a design-first API framework for Go that generates production-ready code
Expand Down Expand Up @@ -154,3 +155,137 @@ will include whatever change was made to its source code.
NOTE2: The `goa gen` command will wipe out the `gen` folder but the
`goa example` command will NOT override pre-existing files (the `cmd` folder and
the top level service files).
=======
## Project Overview

Goa is a design-first framework for building APIs and microservices in Go. It uses a Domain Specific Language (DSL) to define APIs, then generates production-ready code, documentation, and client libraries automatically.

Key value proposition: Instead of writing boilerplate code, developers express their API's intent through a clear DSL, and Goa generates 30-50% of the codebase while ensuring perfect alignment between design, code, and documentation.

## Essential Commands

### Building and Testing
```bash
# Install dependencies and setup tooling
make depend

# Run linter and tests (default target)
make all

# Run linter only
make lint

# Run tests with coverage
make test
# or directly:
go test ./... --coverprofile=cover.out

# Build the goa command
go install ./cmd/goa
```

### Code Generation Workflow
```bash
# Generate service interfaces, endpoints, and transport code from design
# Takes the design Go package path as argument (NOT the file path)
goa gen DESIGN_PACKAGE
# For example
goa gen goa.design/examples/basic/design

# Generate example server and client implementations
goa example DESIGN_PACKAGE

# Common flags
goa gen -o OUTPUT_DIR DESIGN_PACKAGE # Specify output directory
goa gen -debug DESIGN_PACKAGE # Leave temporary files around for debugging
```

## Code Architecture

### High-Level Structure

**DSL → Expression Tree → Code Generation Pipeline → Generated Files**

The framework follows a clean four-phase architecture:

1. **DSL Phase**: Developers write declarative API designs using Goa's DSL
2. **Expression Building**: DSL functions create an expression tree stored in a global Root
3. **Evaluation Pipeline**: Four-phase execution (Prepare → Validate → Finalize → Generate)
4. **Code Generation**: Specialized generators transform expressions into Go code using templates

### Key Packages and Responsibilities

**`/cmd/goa/`** - Main CLI command
- `main.go` - Command parsing with three subcommands: `gen`, `example`, `version`
- `gen.go` - Dynamic generator creation: builds temporary Go program, compiles it, runs it

**`/dsl/`** - Domain Specific Language implementation
- Defines all DSL functions: `API()`, `Service()`, `Method()`, `Type()`, `HTTP()`, `GRPC()`, etc.
- Creates expression structs when DSL functions execute
- Uses dot imports for clean design syntax: `import . "goa.design/goa/v3/dsl"`

**`/eval/`** - DSL execution engine
- Four-phase execution: Parse → Prepare → Validate → Finalize
- Error reporting and context management
- Orchestrates expression evaluation

**`/expr/`** - Expression data structures
- All expression types: `APIExpr`, `ServiceExpr`, `MethodExpr`, `HTTPEndpointExpr`, etc.
- `Root` expression holds entire design tree
- Type system: primitives, arrays, maps, objects, user types

**`/codegen/`** - Code generation infrastructure
- `File` and `SectionTemplate` structures for organizing generated code
- Template rendering with Go code formatting
- Plugin system for extending generation
- `/generator/` - Core generators (Service, Transport, OpenAPI, Example)
- `/service/` - Service-specific code generation (interfaces, endpoints, clients)

**Transport Packages** - Protocol-specific implementations
- `/http/` - HTTP/REST transport with middleware, routing, encoding
- `/grpc/` - gRPC transport with protobuf generation
- `/jsonrpc/` - JSON-RPC transport (work in progress)

### Code Generation Flow

1. **Dynamic Compilation**: Goa creates temporary Go program importing design + codegen libraries
2. **Expression Tree**: DSL execution builds complete API expression tree in memory
3. **Multi-Phase Processing**: Expressions are prepared, validated, and finalized
4. **Specialized Generators**: Different generators handle services, transports, documentation
5. **Template Rendering**: Go templates generate actual source code files
6. **File Writing**: Generated code written to disk with proper formatting

### Design Patterns

**Expression-Based Architecture**: Everything is an expression that implements `Preparer`, `Validator`, `Finalizer` interfaces

**Template-Driven Generation**: All code generated through Go templates in `/templates/` directories

**Transport Abstraction**: Single DSL generates multiple transport implementations (HTTP + gRPC)

**Plugin Architecture**: Extensible through pre/post generation plugins

**Clean Separation**: Business logic stays separate from transport concerns

### Testing Approach

- Extensive golden file testing in `/testdata/` directories
- DSL definitions in `*_dsls.go` files for test scenarios
- Generated code compared against `.golden` files
- Coverage testing with `go test ./... --coverprofile=cover.out`
- Use `make` to run both linting and tests

## Thinking Approach

- Be judicious, remember why you are doing what you are doing
- Do not go for the quick fix / cheat

### Goa Specific

- Always fix the code generator - never edit generated code
- Note: "goa example" does not override existing files - it only creates files that don't exist

## Tools

Take advantage of the Go language server MCP (mcp-gopls)
>>>>>>> b15f1721 (Add JSON-RPC SSE support and integration tests)
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ DEPEND=\
google.golang.org/protobuf/cmd/protoc-gen-go@latest \
google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

all: lint test
all: lint test integration-test

all-tests: lint test integration-test

ci: depend all

Expand Down Expand Up @@ -76,6 +78,14 @@ endif
test:
go test ./... --coverprofile=cover.out

integration-test: build-goa
ifneq ($(GOOS),windows)
cd jsonrpc/integration_tests && go test -count=1 -timeout 10m ./...
endif

build-goa:
cd cmd/goa && go install .

release: release-goa release-examples release-plugins
@echo "Release v$(MAJOR).$(MINOR).$(BUILD) complete"

Expand Down
75 changes: 54 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,24 @@ Traditional API development suffers from:
Goa solves these problems by:
- Generating 30-50% of your codebase directly from your design
- Ensuring perfect alignment between design, code, and documentation
- Supporting multiple transports (HTTP and gRPC) from a single design
- Supporting multiple transports (HTTP, gRPC, and JSON-RPC) from a single design
- Maintaining a clean separation between business logic and transport details

## 🌟 Key Features
## Key Features

- **Expressive Design Language**: Define your API with a clear, type-safe DSL that captures your intent
- **Comprehensive Code Generation**:
- Type-safe server interfaces that enforce your design
- Client packages with full error handling
- Transport layer adapters (HTTP/gRPC) with routing and encoding
- Transport layer adapters (HTTP/gRPC/JSON-RPC) with routing and encoding
- OpenAPI/Swagger documentation that's always in sync
- CLI tools for testing your services
- **Multi-Protocol Support**: Generate HTTP REST and gRPC endpoints from a single design
- **Multi-Protocol Support**: Generate HTTP REST, gRPC, and JSON-RPC endpoints from a single design
- **Clean Architecture**: Business logic remains separate from transport concerns
- **Enterprise Ready**: Supports authentication, authorization, CORS, logging, and more
- **Comprehensive Testing**: Includes extensive unit and integration test suites ensuring quality and reliability

## 🔄 How It Works
## How It Works

```
┌─────────────┐ ┌──────────────┐ ┌─────────────────────┐
Expand All @@ -128,7 +129,7 @@ Goa solves these problems by:
3. **Implement**: Focus solely on writing your business logic in the generated interfaces
4. **Evolve**: Update your design and regenerate code as your API evolves

## 🚀 Quick Start
## Quick Start

```bash
# Install Goa
Expand Down Expand Up @@ -177,9 +178,38 @@ The example above:
2. Generates server and client code
3. Starts a server that logs requests server-side (without displaying any client output)

## 📚 Documentation
### JSON-RPC Alternative

Our completely redesigned documentation site at [goa.design](https://goa.design) provides comprehensive guides and references:
For a JSON-RPC service, simply add a `JSONRPC` expression to the service and
method:

```go
var _ = Service("hello" , func() {
JSONRPC(func() {
Path("/jsonrpc")
})
Method("say_hello", func() {
Payload(func() {
Field(1, "name", String)
Required("name")
})
Result(String)

JSONRPC(func() {})
})
}
```

Then test with:
```bash
curl -X POST http://localhost:8000/jsonrpc \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"hello.say_hello","params":{"name":"world"},"id":"1"}'
```

## Documentation

Our documentation site at [goa.design](https://goa.design) provides comprehensive guides and references:

- **[Introduction](https://goa.design/docs/1-introduction/)**: Understand Goa's philosophy and benefits
- **[Getting Started](https://goa.design/docs/2-getting-started/)**: Build your first Goa service step-by-step
Expand All @@ -188,7 +218,7 @@ Our completely redesigned documentation site at [goa.design](https://goa.design)
- **[Real-World Guide](https://goa.design/docs/5-real-world/)**: Follow best practices for production services
- **[Advanced Topics](https://goa.design/docs/6-advanced/)**: Explore advanced features and techniques

## 🛠️ Real-World Examples
## Real-World Examples

The [examples repository](https://github.com/goadesign/examples) contains complete, working examples demonstrating:

Expand All @@ -202,30 +232,33 @@ The [examples repository](https://github.com/goadesign/examples) contains comple
- **Interceptors**: Request/response processing middleware
- **Multipart**: Handling multipart form submissions
- **Security**: Authentication and authorization examples
- **Streaming**: Implementing streaming endpoints
- **Streaming**: Implementing streaming endpoints (HTTP, WebSocket, JSON-RPC SSE)
- **Tracing**: Integrating with observability tools
- **TUS**: Resumable file uploads implementation

## 🏢 Success Stories

*"Goa reduced our API development time by 40% while ensuring perfect consistency between our documentation and implementation. It's been a game-changer for our microservices architecture."* - Lead Engineer at FinTech Company

*"We migrated 30+ services to Goa and eliminated documentation drift entirely. Our teams can now focus on business logic instead of maintaining OpenAPI specs by hand."* - CTO at SaaS Platform

## 🤝 Community & Support
## Community & Support

- Join the [#goa](https://gophers.slack.com/messages/goa/) channel on Gophers Slack
- Ask questions on [GitHub Discussions](https://github.com/goadesign/goa/discussions)
- Follow us on [Bluesky](https://goadesign.bsky.social)
- Report issues on [GitHub](https://github.com/goadesign/goa/issues)
- Find answers with the [Goa Guru](https://gurubase.io/g/goa) AI assistant

## 📣 What's New
## What's New

**July 2025:** Goa now includes comprehensive **JSON-RPC 2.0 support** as a
first-class transport alongside HTTP and gRPC! Generate complete JSON-RPC
services with streaming support (WebSocket and SSE), client/server code, CLI
tools, and full type safety - all from a single design.

**Jan 2024:** Goa's powerful design DSL is now accessible through the [Goa Design Wizard](https://chat.openai.com/g/g-mLuQDGyro-goa-design-wizard), a specialized AI trained on Goa. Generate service designs through natural language conversations!
**February 2025:** The Goa website has been completely redesigned with extensive
new documentation, tutorials, and guides to help you build better services.

**February 2025:** The Goa website has been completely redesigned with extensive new documentation, tutorials, and guides to help you build better services.
**Jan 2024:** Goa's powerful design DSL is now accessible through the
[Goa Design Wizard](https://chat.openai.com/g/g-mLuQDGyro-goa-design-wizard), a
specialized AI trained on Goa. Generate service designs through natural language
conversations!

## 📄 License
## License

MIT License - see [LICENSE](LICENSE) for details.
Loading
Loading