content

package module
v0.0.0-...-c7f51f0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 7 Imported by: 2

README

DEPRECATED content - very simple Go package to create static content in Go binaries

The embed package in Go since 1.16 should be used instead of this.

The content package is useful when you want to incorporate static content, such as HTML files, in your Go binary. A common use case is static HTML files or template files for a Go-based Web server.

  • Small, simple. straightforward
  • Put your static content files into a directory
  • Write some simple glue code (example included)
  • Run go generate
  • Generated Go source file defines static string constants for each of your static content files
  • Use these string constants in your code

Documentation

Overview

Package content creates static content embedded in your Go binary, such as HTML files for a Web server. You provide the static content in files; then you call GenerateContent at go generate time to create a Go source file. The generated source file defines static const strings, one for each static content file. The generated string for the file 'index.html' is 'Index_html' for example. The constant is in the namespace "staticContent". Note: All files are read into memory, they should not be very big.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateContent

func GenerateContent(staticDir string, outputDir string, outputFile string, packageName string) error

GenerateContent reads all the files in a directory and writes a Go source file with strings containing the bytes in each source file. Intended to be used to incorporate static Web content into a Go binary. staticDir: path to directory containing the files with static content outputDir: path to directory where to write the Go source file outputFile: filename of output Go source file packageName: name of the package to use when writing the Go source file

Types

This section is empty.

Jump to

Keyboard shortcuts

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