Skip to content

StructDeclaration

Go struct declaration.

Properties for creating a struct declaration. This can be used for both named and anonymous structs. For named structs, use StructTypeDeclarationProps instead.

import { StructDeclaration } from "@alloy-js/go";
<StructDeclaration refkey={Refkey} singleLine>
{children}
</StructDeclaration>
childrenoptional Children
refkeyoptional Refkey
singleLineoptional booleanWhether to render the struct in a single line. This will only compile if children is a single line as well. This is not common in Go, so use with caution.
<StructDeclaration>
  <StructEmbed pointer>{MyOtherStruct}</StructEmbed>
  <StructMember exported name="MyProperty" type="int" />
</StructDeclaration>

This will produce:

struct {
  MyOtherStruct
  MyProperty int
}