Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyEmbedded = errors.New("already contains embedded content")
ErrAlreadyEmbedded is returned if the target executable already contains attachments.
var ErrNothingEmbedded = errors.New("contains no embedded data")
ErrNothingEmbedded is returned if the executable does not contain any attachments.
var SkipCompatibilityCheck = false
SkipCompatibilityCheck is used during emeddeding. When the source-executable is compressed (eg. using an exe-packer), the compatibility cannot be confirmed and embedding fails. By setting this flag to true, this compatibility-check will be skipped.
Functions ¶
func Embed ¶
func Embed(out io.Writer, exe io.ReadSeeker, attachments map[string]io.ReadSeeker, logger PrintlnFunc) error
Embed embeds the attachments into the target executable.
out receives the target executable including all attachments.
exe reads from the target executable that should be augmented.
Embed verifies that the target executable is compatible with this version of ember by searching for the magic marker-string (compiled into every executable that imports ember). Embed fails if the executable is incompatible or already contains embedded content.
attachments is a map of attachment names to the corresponding readers for the content.
logger (optional) is used to report the progress during embedding.
Note that all ReadSeekers are seeked to their start before usage, meaning the entirety of readable content is embedded. Use io.SectionReader to avoid this.
func EmbedFiles ¶
func EmbedFiles(out io.Writer, exe io.ReadSeeker, attachments map[string]string, logger PrintlnFunc) error
EmbedFiles embeds the given files into the target executable.
attachments is a map of attachment names to the respective file's filepath.
See Embed for more information.
func RemoveEmbedding ¶ added in v1.1.0
func RemoveEmbedding(out io.Writer, exe io.ReadSeeker, logger PrintlnFunc) error
RemoveEmbedding removes any data embedded with ember from the executable. Returns ErrNothingEmbedded if the executable contains no embedded data.
Any data appended to the executable after ember attached its content will not be preserved.
out receives the cleaned executable with all attachments stripped.
exe reads from the augmented executable that contains attachments.
logger (optional) is used to report the progress during embedding.
Note that the ReadSeeker is seeked to its start before usage. Use io.SectionReader to avoid this.
Types ¶
type PrintlnFunc ¶
type PrintlnFunc func(format string, args ...interface{})
PrintlnFunc is used for logging the embedding progress.