bin2go

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2018 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckVarname

func CheckVarname(f string) bool

func FilenameToVarname

func FilenameToVarname(filename string) (string, error)

filename to variable name conversion:

  1. replace all invalid characters with underscores
  2. squash adjacent underscores
  3. remove trailing underscores
  4. if first character is a number, prepend an underscore

Returns an error if the filename couldn't be converted (i.e. if it contains only underscores or special characters)

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func New

func New(pkg string, files ...string) (*Generator, error)

Create a new bin2go generator with the given package name and input files. Variable names for input files are autogenerated with FilenameToVarname For more granular control, use AddFileVar

func (*Generator) AddFile

func (g *Generator) AddFile(f string) error

Add a file with an autogenerated variable name. The variable name must not already be present.

func (*Generator) AddFileVar

func (g *Generator) AddFileVar(f, v string) error

Add a file with the given variable name. The variable name must be valid and not already present.

func (*Generator) Output

func (g *Generator) Output(w io.Writer) error

Write the full output to the given Writer, this includes the header and all files' data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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