diff options
| author | Shulhan <ms@kilabit.info> | 2021-10-10 01:43:02 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-10-10 01:43:02 +0700 |
| commit | 88504a35592cf0c1a714d0a7454cdf95c7adec8b (patch) | |
| tree | d6d74ccb0aaef9ca2ed816a5e5202a8cc02951e0 /embed_options.go | |
| parent | f48d930a6baec91815fe63e01cb16c4a71867922 (diff) | |
| download | ciigo-88504a35592cf0c1a714d0a7454cdf95c7adec8b.tar.xz | |
all: refactoring with latest share module
The lates share module use the term GoEmbed to generate Go source file.
In order for this repo in sync with upstream terminology and to minimize
confusion, we changes the exported function and command name from
"generate" to "embed", this includes
* Command "ciigo generate" become "ciigo embed"
* Exported function to generate Go renamed from "Generate" to "GoEmbed".
This include the parameter GenerateOptions which renamed to
EmbedOptions.
* The internal command to generate example renamed from "generate" to
"goembed"
Diffstat (limited to 'embed_options.go')
| -rw-r--r-- | embed_options.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/embed_options.go b/embed_options.go new file mode 100644 index 0000000..cc722a1 --- /dev/null +++ b/embed_options.go @@ -0,0 +1,44 @@ +// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package ciigo + +import "github.com/shuLhan/share/lib/memfs" + +// +// EmbedOptions define the options for calling GoEmbed function. +// +type EmbedOptions struct { + ConvertOptions + + // PackageName the name of package in Go generated source code. + // Default to memfs.DefaultEmbedPackageName if its empty. + PackageName string + + // GenVarName the name of variable where all files in Root will be + // stored. + // Default to memfs.DefaultEmbedVarName if its empty. + VarName string + + // GenGoFileName the file name of Go source code will be written. + // Default to memfs.DefaultEmbedGoFileName if its empty. + GoFileName string +} + +func (opts *EmbedOptions) init() (err error) { + err = opts.ConvertOptions.init() + if err != nil { + return err + } + if len(opts.PackageName) == 0 { + opts.PackageName = memfs.DefaultEmbedPackageName + } + if len(opts.VarName) == 0 { + opts.VarName = memfs.DefaultEmbedVarName + } + if len(opts.GoFileName) == 0 { + opts.GoFileName = memfs.DefaultEmbedGoFileName + } + return nil +} |
