mime

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameExt  = "ext"
	NameMime = "mime"
)

Variables

View Source
var (
	ErrDuplicate = errors.New("duplicate")
	ErrNotFound  = errors.New("not found")
)

Functions

func Create

func Create(tpl *template.Template, name string, cfg Config) error

func Format

func Format(name string) error

Format file and write it.

func Generate

func Generate(fileName string, opts ...Option) error

func Value

func Value(prefix string, val []string) string

func VarName

func VarName(prefix, name string) string

Types

type Config

type Config struct {
	Source string

	Mimes       []Data `yaml:"mime"`
	MimePrefix  string
	MimeTpl     string
	MimeResult  string
	MimePackage string

	Extensions []Data `yaml:"ext"`
	ExtPrefix  string
	ExtTpl     string
	ExtResult  string
	ExtPackage string
}

func (*Config) Base

func (c *Config) Base(name string) string

func (*Config) Result

func (c *Config) Result(name string) string

func (*Config) ValidateAndFillExt

func (c *Config) ValidateAndFillExt() error

type Data

type Data struct {
	Name  string   `yaml:"name"`
	ID    int      `yaml:"id"`
	Value []string `yaml:"value,omitempty"`
}

type Option

type Option func(*Config)

func WithExtPacakge

func WithExtPacakge(name string) Option

func WithExtResult

func WithExtResult(name string) Option

func WithExtTpl

func WithExtTpl(name string) Option

func WithMimePackage

func WithMimePackage(name string) Option

func WithMimeResult

func WithMimeResult(name string) Option

func WithMimeTpl

func WithMimeTpl(name string) Option

Jump to

Keyboard shortcuts

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