Documentation
¶
Overview ¶
Package iconutil discovers the package icon at the package root and exposes its on-disk and decoded properties as a single Icon value.
The convention is `icon.<ext>` at the package root. Find walks any matching file (not only registered formats) so callers can validate the extension as a separate concern; supported formats live in the unexported formats registry — adding one is a single entry plus the matching import.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoIcon = errors.New("icon not found")
ErrNoIcon is returned by Find when no icon.* file is present at packageDir.
Functions ¶
Types ¶
type Icon ¶
type Icon struct {
// Path is the absolute path to the icon file on disk.
Path string
// Ext is the file extension including the leading dot (e.g. ".png").
// May be an unsupported extension — callers should validate it (see ExtRule).
Ext string
// Size is the icon file size in bytes.
Size int64
// Shape carries the rendered width and height. Zero when the format is
// unsupported, decoding failed, or the format is vector with no intrinsic
// rasterized size.
Shape image.Config
}
Icon is a discovered package icon with its on-disk and decoded properties.
func Find ¶
Find discovers any icon.* file at packageDir, reads its size, and tries to decode its dimensions when the extension is supported.
Returned states:
- (Icon{}, ErrNoIcon) no icon.* file exists
- (Icon{Path,Ext,Size}, decodeErr) content cannot be decoded
- (Icon{Path,Ext,Size}, nil) extension unsupported (Shape zero)
- (Icon{Path,Ext,Size,Shape}, nil) full success
- (partial Icon, os-level error) filesystem ops failed