Skip to content

Conversation

@findleyr
Copy link
Contributor

@findleyr findleyr commented Jun 25, 2025

After some experience with the flattened version of Content, we see that
it can easily lead to incorrect usage and is a harder API to read.
Therefore, this CL changes back to a design similar to what we had prior
to https://go.dev/cl/672415, though opting to promote content
unmarshalling to the protocol types that use it, which leads to an
overall simpler api.

@findleyr findleyr force-pushed the findleyr/content branch 3 times, most recently from 90dec94 to 77f7e59 Compare June 25, 2025 14:25
@jba
Copy link
Contributor

jba commented Jun 25, 2025

Truncated commit message.

@findleyr
Copy link
Contributor Author

Truncated commit message.

Whoops (I copy-pasted to update the PR description). Fixed. Still getting used to GitHub.

Blob []byte `json:"blob,omitempty"` // if nil, then text; else blob
URI string `json:"uri,"`
MIMEType string `json:"mimeType,omitempty"`
Text string `json:"text,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had talked about using the same interface-plus-concrete-types pattern here, for consistency. Why aren't we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that, and it added a lot of code and complexity for little value. Unlike contents, this isn't a distinguished union: the presence of text or blob determines its type, and otherwise the types are the same. We can make it an interface, but maybe in a later CL?

After some experience with the flattened version of Content, we see that
it can easily lead to incorrect usage and is a harder API to read.
Therefore, this CL changes back to a design similar to what we had prior
to https://go.dev/cl/672415, though opting to promote content
unmarshalling to the protocol types that use it, which leads to an
overall simpler api.
@findleyr findleyr merged commit 204b594 into main Jun 25, 2025
2 checks passed
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.

3 participants