pkgassets

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2017 License: BSD-3-Clause Imports: 2 Imported by: 0

README

pkgassets

Generate a Go source file with embedded file assets. This is useful where you want to embed web content, template source code and other assets that can be used for default behavior in a Go command line program or service.

USAGE

    pkgassets MAP_VAR_NAME NAME_OF_DIRECTORY_HOLDING_ASSETS

This will result in a Go map[string][]byte structure holding the assets discovered by walking the directory tree provided. The map's key will represent a path (beginning with "/") pointing at the asset ingested.

    pkgassets DefaultSite htdocs

Assuming that htdocs held

  • index.html
  • css/site.css

In this example the htdocs directory will be crawled and all the files found harvested as a an asset. The path in the map will not include htdocs and would result in a Go source file, defaultsite.go would like

    package defaultsite

    var DefaultSite = map[string][]byte{
        "/index.html": []byte("... the contents of index.html would be here ..."),
        "/css/site.css": []byte("... the contents of css/site.css would be here ..."),
    }

If a package name is not provided then the package name will be assumed to be the name of the file. The Asset option will also be assume to be the name of the file.

OPTIONS

  • -h, -help will display the help page
  • -l, -license will display license info
  • -v, -version will display version info
  • -o, -output will set the name of the file output otherwise it defaults to package name in lowercase plus the ".go" extension
  • -p, -package will set the name of the package if missing it defaults to a lower case version of map variable name
  • -c, -comment will include a file as a comment in the head of the source file created (e.g. for your copyright statement)

Documentation

Overview

pkgassets is a command line tool for harvesting directory contents (like website default files) and turning them into a Go package with a map of path and byte array of contents harvested.

@Author R. S. Doiel, <rsdoiel@caltechlibrary.edu>

Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "v0.0.1"

	LicenseText = `` /* 1530-byte string literal not displayed */

)

Functions

func ByteArrayToDecl added in v0.0.1

func ByteArrayToDecl(src []byte) (string, error)

ByteArrayToDecl converts the contents of the file pointed to by fname into a Byte array declaration.

Types

This section is empty.

Directories

Path Synopsis
cmds
pkgassets command

Jump to

Keyboard shortcuts

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