Skip to content

go: Add support for struct enums#1829

Merged
svix-mman merged 7 commits intomainfrom
mendy/go-struct-enums
Mar 21, 2025
Merged

go: Add support for struct enums#1829
svix-mman merged 7 commits intomainfrom
mendy/go-struct-enums

Conversation

@svix-mman
Copy link
Contributor

@svix-mman svix-mman commented Mar 20, 2025

This is what the API will look like

// struct enum with fields
sourceIn := models.IngestSourceIn{
	Name: "Mendy",
	Type: models.IngestSourceInTypeCron,
	Config: models.CronConfig{
		Payload:  "Hello from space",
		Schedule: "0 0 0 * *",
	},
}

// struct enum without fields
uid := "very unique"
sourceIn := models.IngestSourceIn{
	Name: "Mendy",
	Uid: &uid
	Type: models.IngestSourceInTypeGenericWebhook,
}

// read a field
if cronConfig, ok := sourceIn.Config.(models.CronConfig); ok {
	println(cronConfig.Payload)
}

edit(jplatte): Closes https://github.com/svix/monorepo-private/issues/9981, closes https://github.com/svix/monorepo-private/issues/10059

@svix-mman svix-mman requested a review from a team as a code owner March 20, 2025 19:54
@svix-mman svix-mman merged commit b8eaad2 into main Mar 21, 2025
11 checks passed
@svix-mman svix-mman deleted the mendy/go-struct-enums branch March 21, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments