Skip to content

InterfaceDeclaration

Go interface declaration.

Properties for creating an interface declaration. This can be used for both named and anonymous interfaces. For named interfaces, use InterfaceTypeDeclarationProps instead.

import { InterfaceDeclaration } from "@alloy-js/go";
<InterfaceDeclaration refkey={Refkey} singleLine>
{children}
</InterfaceDeclaration>
childrenoptional Children
refkeyoptional Refkey
singleLineoptional booleanWhether to render the interface 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.
<InterfaceDeclaration>
  <InterfaceEmbed>{MyOtherInterface}</InterfaceEmbed>
  <InterfaceFunction name="MyFunc" parameters={params} returns="int" />
</InterfaceDeclaration>

This will produce:

interface {
  MyOtherInterface
  func MyFunc(param Param) int
}