MCPcopy Index your code
hub / github.com/aws/smithy-go

github.com/aws/smithy-go @v1.27.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.27.3 ↗ · + Follow
5,000 symbols 17,683 edges 517 files 2,229 documented · 45% 348 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Smithy Go

Go Build StatusCodegen Build Status

Smithy code generators for Go and the accompanying smithy-go runtime.

The smithy-go runtime requires a minimum version of Go 1.24.

WARNING: All interfaces are subject to change.

:warning: Client codegen is unstable

The client code generator in this repository powers the aws-sdk-go-v2. Arbitrary client generation, while technically possible, is in an early stage of development:

  • Generated clients are missing certain features that were originally implemented SDK-side (e.g. retries)
  • There may be bugs
  • The public APIs of generated clients may be unstable

If you are interested in using the client code generators, we encourage you to experiment and share any feedback with us in an issue.

Plugins

This repository implements the following Smithy build plugins:

ID GAV prefix Description
go-codegen software.amazon.smithy.go:smithy-go-codegen Implements Go client code generation for Smithy models.
go-server-codegen software.amazon.smithy.go:smithy-go-codegen Implements Go server code generation for Smithy models.
go-shape-codegen software.amazon.smithy.go:smithy-go-codegen Implements Go shape code generation (types only) for Smithy models.

NOTE: Build plugins are not currently published to mavenCentral. You must publish to mavenLocal to make the build plugins visible to the Smithy CLI. The artifact version is currently fixed at 0.1.0.

go-codegen

Configuration

GoSettings contains all of the settings enabled from smithy-build.json and helper methods and types. The up-to-date list of top-level properties enabled for go-client-codegen can be found in GoSettings::from().

Setting Type Required Description
service string yes The Shape ID of the service for which to generate the client.
module string yes Name of the module in generated.json (and go.mod if generateGoMod is enabled) and doc.go.
generateGoMod boolean Whether to generate a default go.mod file. The default value is false.
goDirective string Go directive of the module. The default value is the minimum supported Go version.

Supported protocols

The protocol a client uses is configured by the Protocol field on a client's Options. The SDK will configure a default based on the protocol traits applied to the modeled service.

Protocol Notes
smithy.protocols#rpcv2Cbor
aws.protocols#restJson1
aws.protocols#restXml
aws.protocols#awsJson1_0
aws.protocols#awsJson1_1
aws.protocols#awsQuery
aws.protocols#ec2Query

Example

This example applies the go-codegen build plugin to the Smithy quickstart example created from smithy init:

{
  "version": "1.0",
  "sources": [
    "models"
  ],
  "maven": {
    "dependencies": [
      "software.amazon.smithy.go:smithy-go-codegen:0.1.0"
    ]
  },
  "plugins": {
    "go-codegen": {
      "service": "example.weather#Weather",
      "module": "github.com/example/weather",
      "generateGoMod": true,
      "goDirective": "1.24"
    }
  }
}

go-server-codegen

This plugin is a work-in-progress and is currently undocumented.

go-shape-codegen

This plugin is a work-in-progress and is currently undocumented.

License

This project is licensed under the Apache-2.0 License.

Extension points exported contracts — how you extend this code

PropertiesReader (Interface)
PropertiesReader provides an interface for reading metadata from the underlying metadata container. [9 implementers]
properties.go
Trait (Interface)
Trait represents a trait applied to a shape in a Smithy model. Traits related to (de)serialization are included in code- [26 …
trait.go
ShapeSerializer (Interface)
ShapeSerializer implements the marshaling of an in-code representation of a shape to an unspecified data format, which i [6 …
serde.go
FinalizeHandler (Interface)
FinalizeHandler provides the interface for the next handler the FinalizeMiddleware will call in the middleware chain. [9 …
middleware/step_finalize.go
DeserializeHandler (Interface)
DeserializeHandler provides the interface for the next handler the DeserializeMiddleware will call in the middleware cha [10 …
middleware/step_deserialize.go
BuildHandler (Interface)
BuildHandler provides the interface for the next handler the BuildMiddleware will call in the middleware chain. [9 implementers]
middleware/step_build.go
Middleware (Interface)
Middleware provides the interface to call handlers in a chain. [7 implementers]
middleware/middleware.go
MetadataReader (Interface)
MetadataReader provides an interface for reading metadata from the underlying metadata container. [9 implementers]
middleware/metadata.go

Core symbols most depended-on inside this repo

Errorf
called by 995
testing/doc.go
write
called by 917
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/integration/HttpProtocolGeneratorUtils.java
goTemplate
called by 465
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoWriter.java
of
called by 238
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/knowledge/GoUsageIndex.java
getName
called by 226
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/integration/DocumentShapeSerVisitor.java
get
called by 225
middleware/step_build.go
addUseImports
called by 204
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoWriter.java
toSymbol
called by 191
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/SymbolVisitor.java

Shape

Method 3,153
Function 983
Struct 425
Class 243
Interface 111
TypeAlias 60
FuncType 20
Enum 5

Languages

Go60%
Java40%

Modules by API surface

codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/integration/HttpProtocolUnitTestGenerator.java86 symbols
eventstream/header_value.go73 symbols
serde.go60 symbols
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/integration/HttpBindingProtocolGenerator.java55 symbols
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/integration/ProtocolGenerator.java53 symbols
transport/http/protocol/internal/json/benchmark_test.go51 symbols
ptr/to_ptr.go51 symbols
ptr/from_ptr.go51 symbols
ptr/to_ptr_test.go48 symbols
metrics/metrics.go47 symbols
transport/http/protocol/internal/json/shape_deserializer.go45 symbols
codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoWriter.java45 symbols

For agents

$ claude mcp add smithy-go \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact