Help us shape the future of Go! Take the 2026 Go Developer Survey

iconutil

package
v0.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

View Source
var ErrNoIcon = errors.New("icon not found")

ErrNoIcon is returned by Find when no icon.* file is present at packageDir.

Functions

func Expected

func Expected() string

Expected returns the conventional icon path(s) for diagnostics — "icon.png" when only one format is registered, "icon.{png,webp,...}" otherwise.

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

func Find(packageDir string) (Icon, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL