Convert tagged Go structs into Kakao Work Block Kit, Slack Block Kit, and Google Chat Cards v2 messages. Each messenger uses its own tag namespace, so the same source struct can describe messages for several platforms.
Go 1.25 or later is required.
go get github.com/JSYoo5B/convertagopackage main
import (
"encoding/json"
"fmt"
"github.com/JSYoo5B/convertago"
)
type Notice struct {
Title string `kakaowork:"header" slack:"header" googlechat:"header"`
Prefix string `kakaowork:"text;group=body" slack:"rich_text;group=body" googlechat:"textParagraph;group=body"`
Name string `kakaowork:"text;group=body;style=bold" slack:"rich_text;group=body;style=bold" googlechat:"textParagraph;group=body;style=bold"`
}
func main() {
notice := Notice{Title: "Notice", Prefix: "Hello ", Name: "Jane"}
message, err := convertago.ToSlackMessage(notice)
if err != nil {
panic(err)
}
data, err := json.MarshalIndent(message, "", " ")
if err != nil {
panic(err)
}
fmt.Println(string(data))
}ToKakaoworkMessage, ToSlackMessage, and ToGoogleChatMessage accept a struct
or a non-nil pointer to one. They return the corresponding native message
and an error. The sending application handles message delivery.
Fields contribute in declaration order. group joins fields into one native
node; include any spaces or newlines in the source values. An absent tag, an
empty tag, or - excludes a field for that platform. See the
tag conversion guide for nesting, slots, omission, and severity
diagnostics.
Each package documents its supported roles, slots, styles, and validation rules. Its native models are also available for constructing or editing messages directly. Conversion implementations live in the corresponding messenger package.
Known struct types can use generated field accessors. Add this directive to the
source package and run go generate:
//go:generate go run github.com/JSYoo5B/convertago/cmd/convertago -type Notice -output zz_convertago.gen.goCommit the generated file alongside the source. The conversion functions select generated accessors automatically and otherwise use cached reflection. Dynamic interface fields retain a reflection fallback. Both paths share tag semantics and validation. See the generation guide for supported source types, regeneration, and cross compilation.
| Guide | Contents |
|---|---|
| Message rules | Rule sources, severities, evidence, and UX defaults. |
| Documentation policy | Documentation language and required README, godoc, and example contents. |
| Adding a platform | Native model conventions, required tests, and steps for a new messenger. |
| Tag conversion | Grammar, builders, ordering, groups, nesting, omissions, and diagnostics. |
| Code generation | Generator usage, generated-code contract, and target-specific layouts. |
| Development | Repository layout, test placement, CI, fuzzing, and cross-build checks. |
| Benchmark execution | Allocation reporting, process CPU, and peak memory measurements. |
| Benchmark results | Recorded reflection-cache and generated-accessor comparisons. |
MIT.