Skip to content

sys/png: move SysDecodePng to separate subpackage#9

Merged
mitchellh merged 1 commit intomainfrom
push-suyvllymsktt
Apr 11, 2026
Merged

sys/png: move SysDecodePng to separate subpackage#9
mitchellh merged 1 commit intomainfrom
push-suyvllymsktt

Conversation

@mitchellh
Copy link
Copy Markdown
Owner

Fixes #6

The root libghostty package previously imported image/png for SysDecodePng. Because image/png registers itself via an init() function, the Go linker cannot eliminate it from binaries that never call SysDecodePng. Every consumer paid the cost.

Move the built-in PNG decoder into sys/png so users opt in explicitly. The root package no longer imports image or image/png. The kitty_graphics_test.go file inlines a local test helper to avoid the import cycle that would result from an internal test package importing its own subpackage.

Fixes #6

The root libghostty package previously imported image/png for
SysDecodePng. Because image/png registers itself via an init()
function, the Go linker cannot eliminate it from binaries that
never call SysDecodePng. Every consumer paid the cost.

Move the built-in PNG decoder into sys/png so users opt in
explicitly. The root package no longer imports image or image/png.
The kitty_graphics_test.go file inlines a local test helper to
avoid the import cycle that would result from an internal test
package importing its own subpackage.
@mitchellh mitchellh merged commit e65c115 into main Apr 11, 2026
26 checks passed
@@ -1,17 +1,43 @@
package libghostty
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Changing to an external test would allow to use sys/png.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Yeah it would but sys/png is tested in isolation and we just want to verify the basic graphics APIs work here. I think its fine to duplicate and have no dependency.

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.

Move SysDecodePng to a separate package

2 participants