pack

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package pack writes what packaging needs without the platform's tools: icons (.icns, .ico), Info.plist, the NSIS installer script. Used by the macOS engine at runtime (the engine copy's icon) and by the lightron command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePNG

func DecodePNG(b []byte) (image.Image, error)

DecodePNG reads a PNG.

func ICNS

func ICNS(src image.Image) []byte

ICNS writes a macOS .icns from a square image: PNG entries at the sizes Finder, the Dock and Retina screens ask for (macOS 10.7 and later read PNG entries), so no iconutil is needed.

func ICO

func ICO(src image.Image, sizes []int, bmp bool) []byte

ICO writes a Windows .ico from a square image at the given sizes (≤256). PNG entries (Windows Vista and later), or classic 32-bit bitmaps when bmp: NSIS's installer icon needs those (makensis aborts on PNG entries).

func NSISScript

func NSISScript(d NSIS) (string, error)

NSISScript is the Windows installer (makensis): per user, no admin rights, into %LOCALAPPDATA%\Programs\<Name>; Start menu and desktop shortcuts; an entry in Installed apps; it starts the app when done. An update runs it with /S (update.Install): it installs over the installed one, then starts it, showing its progress window all the same. It waits up to five seconds for a running app to quit before killing it (an older updater quits after starting it).

func PNG

func PNG(img image.Image) []byte

PNG encodes img.

func Plist

func Plist(values map[string]any) []byte

Plist writes an Info.plist of string and boolean values.

func Scale

func Scale(src image.Image, n int) *image.NRGBA

Scale draws src at n×n, each target pixel the average of the source pixels it covers (alpha-weighted, so transparent corners don't darken the edges). Downscaling only, which is what icons need.

func WindowsResources

func WindowsResources(w io.Writer, arch string, icon image.Image, name, ver, company string) error

WindowsResources writes a .syso the Go linker puts into the .exe (it picks up *.syso of the package it builds): the icon Explorer and the taskbar show, a manifest (per-monitor v2 DPI, common controls v6), version information.

func Zip

func Zip(dst, dir string) error

Zip writes dir into dst with dir's own name as the top folder, keeping file modes and symlinks (a .app needs both: its executables and the framework links). macOS's Archive Utility and ditto restore them.

Types

type NSIS

type NSIS struct {
	Name, Version, Publisher string
	Exe                      string   // the app's .exe, installed as is
	Files                    []string // absolute paths of the files to install next to the exe (the exe included)
	Dirs                     []NSISDir
	Include                  string   // an NSIS script to !include; its macro preInstall runs before the files are copied
	Out                      string   // the installer's path
	Icon                     string   // a bitmap .ico for the installer itself
	ShortcutIcon             string   // the .ico installed for shortcuts (one of Files' names), "" = the exe's
	RegKey                   string   // the uninstall registry key's name
	Protocols                []string // URL schemes: registered for the current user (the app also does at each start)
}

NSIS is what the installer script needs.

type NSISDir added in v0.4.0

type NSISDir struct{ Dest, Src string }

NSISDir is a directory to install: Src's contents into $INSTDIR\Dest (Dest with forward slashes).

Jump to

Keyboard shortcuts

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