sdkshape

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sdkshape parses a pinned aws-sdk-go-v2 service module's own generated source (api_op_*.go, types/types.go) into its declared request/response struct shapes: field name, declared Go type, and whether the SDK's doc comment marks it required. This is ground truth shared by cmd/structfielddiff (full field dumps for hand comparison) and cmd/enumcheck (resolving a gopherstack struct field to its one real SDK member type), so both read the exact same parse instead of two implementations drifting apart.

The SDK's own generated types carry no encoding/json struct tags at all -- the wire name for a JSON-family protocol field IS the Go field name -- so this needs no tag handling, only the field name and its declared type.

Parsed with go/ast, not a line/brace-counting scan: an earlier version counted "{"/"}" per line including inside doc comments, and AWS's own doc comments routinely show unbalanced example braces (a JSON snippet, a mid-sentence "{"), which silently threw off the brace depth and skipped every struct declared after the first such comment in a file -- confirmed live against sagemaker@v1.263.2's types.go, which lost ~500 of ~1600 real structs (including TrainingJob itself) this way. go/ast can't miscount: a comment is trivia, never struct syntax.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BareTypeName

func BareTypeName(t string) string

BareTypeName strips pointer/slice/map decoration and a "types." or other package-qualifier prefix, returning the identifier a struct lookup uses (e.g. "*types.ClusterStatus" -> "ClusterStatus", "[]*types.Tag" -> "Tag", "map[string]*string" -> "string").

func LoadModuleStructs

func LoadModuleStructs(modPath string) (map[string]StructDef, []string, error)

LoadModuleStructs reads every api_op_<Op>.go file (for op names and their Input/Output structs) and types/types.go (for nested structs) under modPath, returning every struct found keyed by bare name, plus the sorted list of operation names.

Types

type Field

type Field struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Required bool   `json:"required"`
}

Field is one declared field of a pinned SDK struct.

type StructDef

type StructDef struct {
	Name   string  `json:"name"`
	Fields []Field `json:"fields"`
}

StructDef is one pinned SDK "type X struct { ... }" declaration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL