Documentation
¶
Overview ¶
Package selfexec embeds a pact document into an executable and reads it back.
Format (appended to the binary):
[ pact binary bytes ] [ document content (UTF-8) ] [ 8 bytes: magic "PACTDOC1" ] [ 8 bytes: content length (uint64 little-endian) ]
Index ¶
- func HasAllPlatforms() bool
- func InstallAndRegister(exePath string)
- func InstallCopy(exePath, home string) string
- func Read(path string) (string, bool)
- func ReplaceFile(path string, data []byte, perm os.FileMode) error
- func UnderTempDir(path string) bool
- func WriteForPlatform(goos, goarch, content, outPath string) error
- func WritePact(content, outPath string) error
- func WriteZip(content, outPath string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasAllPlatforms ¶
func HasAllPlatforms() bool
HasAllPlatforms reports whether all supported platform binaries are embedded. True only when built with -tags with_platforms (i.e. 'make dist').
func InstallAndRegister ¶
func InstallAndRegister(exePath string)
InstallAndRegister makes pact durable on this machine: it copies the running binary into the per-OS install location (so pact survives the downloaded file being deleted) and registers the installed copy as the default editor for .pact files. Called in the background on every regular (non self-executing) startup; cheap when everything is already in place.
func InstallCopy ¶
InstallCopy ensures the durable copy exists and matches the running binary, refreshing it after an upgrade. If the running binary carries embedded binaries for other platforms (dist build), it also updates those in their respective home-directory install locations.
It returns the path registration should point at: the installed copy for the current platform when available, the running binary when installing failed.
func Read ¶
Read checks the file at path for an embedded pact document. Returns the document content and true if found.
func WriteForPlatform ¶
WriteForPlatform saves the document as a self-contained executable for the given goos/goarch. Uses an embedded pre-compiled binary when available (dist build), otherwise falls back to the running binary for the current platform.
For darwin, outPath must end with ".app" when creating a new bundle; the function creates the full .app directory structure with icon and launcher. When called with a plain path (e.g. during post-sign self-overwrite inside an existing bundle), it writes a plain binary file.
func WritePact ¶
WritePact saves the document content as XML-based .pact data readable by selfexec.Read. content may be a plain-text pact body or a pre-built pact XML document.
Types ¶
This section is empty.
Source Files
¶
- install.go
- register.go
- register_stub.go
- selfexec.go