codegen

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Standard library types
	XMLNameIdent      = GoIdent{GoImportPath: "encoding/xml", GoName: "Name"}
	XMLAttrIdent      = GoIdent{GoImportPath: "encoding/xml", GoName: "Attr"}
	ContextIdent      = GoIdent{GoImportPath: "context", GoName: "Context"}
	TimeIdent         = GoIdent{GoImportPath: "time", GoName: "Time"}
	BytesBufferIdent  = GoIdent{GoImportPath: "bytes", GoName: "Buffer"}
	HTTPClientIdent   = GoIdent{GoImportPath: "net/http", GoName: "Client"}
	HTTPRequestIdent  = GoIdent{GoImportPath: "net/http", GoName: "Request"}
	HTTPResponseIdent = GoIdent{GoImportPath: "net/http", GoName: "Response"}
	IOReaderIdent     = GoIdent{GoImportPath: "io", GoName: "Reader"}
	IOReadCloserIdent = GoIdent{GoImportPath: "io", GoName: "ReadCloser"}

	// Standard library functions
	FmtSprintfIdent                = GoIdent{GoImportPath: "fmt", GoName: "Sprintf"}
	FmtErrorfIdent                 = GoIdent{GoImportPath: "fmt", GoName: "Errorf"}
	XMLMarshalIdent                = GoIdent{GoImportPath: "encoding/xml", GoName: "Marshal"}
	XMLUnmarshalIdent              = GoIdent{GoImportPath: "encoding/xml", GoName: "Unmarshal"}
	HTTPNewRequestWithContextIdent = GoIdent{GoImportPath: "net/http", GoName: "NewRequestWithContext"}
	HTTPStatusOKIdent              = GoIdent{GoImportPath: "net/http", GoName: "StatusOK"}
	BytesNewReaderIdent            = GoIdent{GoImportPath: "bytes", GoName: "NewReader"}
	IOReadAllIdent                 = GoIdent{GoImportPath: "io", GoName: "ReadAll"}

	// SOAP library types
	SOAPClientIdent       = GoIdent{GoImportPath: "github.com/way-platform/soap-go", GoName: "Client"}
	SOAPClientOptionIdent = GoIdent{GoImportPath: "github.com/way-platform/soap-go", GoName: "ClientOption"}
	SOAPNewClientIdent    = GoIdent{GoImportPath: "github.com/way-platform/soap-go", GoName: "NewClient"}
	SOAPWithEndpointIdent = GoIdent{GoImportPath: "github.com/way-platform/soap-go", GoName: "WithEndpoint"}
	SOAPEnvelopeIdent     = GoIdent{GoImportPath: "github.com/way-platform/soap-go", GoName: "Envelope"}
	SOAPBodyIdent         = GoIdent{GoImportPath: "github.com/way-platform/soap-go", GoName: "Body"}
	SOAPNamespaceIdent    = GoIdent{GoImportPath: "github.com/way-platform/soap-go", GoName: "Namespace"}
	SOAPNewEnvelopeIdent  = GoIdent{GoImportPath: "github.com/way-platform/soap-go", GoName: "NewEnvelope"}
	SOAPWithBodyIdent     = GoIdent{GoImportPath: "github.com/way-platform/soap-go", GoName: "WithBody"}

	// Built-in types (no import path needed)
	StringIdent = GoIdent{GoImportPath: "", GoName: "string"}
	IntIdent    = GoIdent{GoImportPath: "", GoName: "int"}
	BoolIdent   = GoIdent{GoImportPath: "", GoName: "bool"}
	ByteIdent   = GoIdent{GoImportPath: "", GoName: "byte"}
	ErrorIdent  = GoIdent{GoImportPath: "", GoName: "error"}
)

Common Go identifiers used in generated code. These provide type-safe access to commonly used types and functions.

Functions

This section is empty.

Types

type File

type File struct {
	// contains filtered or unexported fields
}

File represents a generated Go file.

func NewFile

func NewFile(filename, goImportPath string) *File

NewFile creates a new File with the given filename and import path.

func (*File) Content

func (g *File) Content() ([]byte, error)

Content returns the contents of the generated file.

func (*File) Filename added in v0.5.0

func (g *File) Filename() string

Filename returns the filename of the file.

func (*File) Import

func (f *File) Import(importPath string)

Import adds a blank import to the file (for side effects). For normal imports, use QualifiedGoIdent instead.

func (*File) P

func (g *File) P(v ...any)

P writes a line of code to the file.

func (*File) QualifiedGoIdent added in v0.21.0

func (f *File) QualifiedGoIdent(ident GoIdent) string

QualifiedGoIdent returns the qualified Go identifier and manages imports automatically. If the identifier is from the same package, returns just the name. If from a different package, returns packageName.Name and ensures the import is added.

func (*File) SetPackageName added in v0.21.0

func (f *File) SetPackageName(importPath string, packageName string)

SetPackageName sets a custom package name for the given import path. This allows overriding the default package name derivation.

func (*File) Write

func (g *File) Write(p []byte) (n int, err error)

Write implements io.Writer.

type GoIdent added in v0.21.0

type GoIdent struct {
	GoImportPath string // Import path, e.g., "encoding/xml"
	GoName       string // Identifier name, e.g., "Name"
}

GoIdent represents a Go identifier with its import path.

type GoPackageName added in v0.21.0

type GoPackageName string

GoPackageName represents a package name used in generated code.

Jump to

Keyboard shortcuts

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