This section is empty.


View Source
var ErrAlreadyEmbedded = errors.New("already contains embedded content")

    ErrAlreadyEmbedded is returned if the target executable already contains attachments.


    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 VerifyCompatibility

        func VerifyCompatibility(exe io.ReadSeeker, marker string) error

          VerifyCompatibility ensures that the target executable is compatible and not already augmented. This means that the target executable contains the magic-string "marker" that is compiled into the executable, which can be easily done by defining it in a global variable and using it in the init() function to ensure that it is not optimized away by the go linker. An example can be seen in maja42/ember/marker.go

          (Note that the calling function's application should build this marker programmatically.
           Otherwise it will end up in the embeder's executable as well, letting it appear compatible.)

          Returns ErrAlreadyEmbedded if the target executable already contains attachments. The reader is seeked to the beginning afterwards.


          type PrintlnFunc

          type PrintlnFunc func(format string, args ...interface{})

            PrintlnFunc is used for logging the embedding progress.

            Source Files