aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-10-27 22:01:43 +0700
committerShulhan <ms@kilabit.info>2021-10-27 22:01:43 +0700
commit0bfe10781a53474fba2ab2b3f933df6b7e0a4e70 (patch)
treef929439ebaa4c1b58bac05925f21e693a20ab8e6
parent36d729c71dd03303a2eef4cfefa64ac1a78a0ec1 (diff)
downloadciigo-0bfe10781a53474fba2ab2b3f933df6b7e0a4e70.tar.xz
all: update to latest share module
The latest share module simplify the memfs.GoEmbed call by using struct memfs.EmbedOptions instead of passing it as parameters. The changes on share module affect on how EmbedOptions in this module, where memfs.EmbedOptions is used to replace field PackageName, VarName, and GoFileName.
-rw-r--r--README.md12
-rw-r--r--ciigo.go5
-rw-r--r--cmd/ciigo/main.go5
-rw-r--r--embed_options.go14
-rw-r--r--go.mod2
-rw-r--r--go.sum4
-rw-r--r--internal/cmd/goembed/main.go9
7 files changed, 25 insertions, 26 deletions
diff --git a/README.md b/README.md
index e0492d6..aa0cf95 100644
--- a/README.md
+++ b/README.md
@@ -153,16 +153,18 @@ import (
)
func main() {
- opts := &ciigo.GenerateOptions{
+ opts := &ciigo.EmbedOptions{
ConvertOptions: ciigo.ConvertOptions{
Root: "./_contents",
HtmlTemplate: "_contents/html.tmpl",
},
- GenPackageName: "main",
- GenVarName: "mysiteFS",
- GenGoFileName: "cmd/mysite/static.go",
+ EmbedOptions: memfs.EmbedOptions{
+ PackageName: "main",
+ VarName: "mysiteFS",
+ GoFileName: "cmd/mysite/static.go",
+ },
}
- ciigo.Generate(opts)
+ ciigo.GoEmbed(opts)
}
```
diff --git a/ciigo.go b/ciigo.go
index d25d1c7..14c2202 100644
--- a/ciigo.go
+++ b/ciigo.go
@@ -117,7 +117,10 @@ func GoEmbed(opts *EmbedOptions) (err error) {
memfsOpts := &memfs.Options{
Root: opts.Root,
Excludes: defExcludes,
+ Embed: opts.EmbedOptions,
}
+ memfsOpts.Embed.ContentEncoding = memfs.EncodingGzip
+
mfs, err = memfs.New(memfsOpts)
if err != nil {
return fmt.Errorf("%s: %w", logp, err)
@@ -130,7 +133,7 @@ func GoEmbed(opts *EmbedOptions) (err error) {
}
}
- err = mfs.GoEmbed(opts.PackageName, opts.VarName, opts.GoFileName, memfs.EncodingGzip)
+ err = mfs.GoEmbed()
if err != nil {
return fmt.Errorf("%s: %w", logp, err)
}
diff --git a/cmd/ciigo/main.go b/cmd/ciigo/main.go
index b33b062..4701c68 100644
--- a/cmd/ciigo/main.go
+++ b/cmd/ciigo/main.go
@@ -40,6 +40,7 @@ import (
"git.sr.ht/~shulhan/ciigo"
"github.com/shuLhan/share/lib/debug"
+ "github.com/shuLhan/share/lib/memfs"
)
func main() {
@@ -91,7 +92,9 @@ func main() {
HtmlTemplate: *htmlTemplate,
Exclude: *exclude,
},
- GoFileName: *outputFile,
+ EmbedOptions: memfs.EmbedOptions{
+ GoFileName: *outputFile,
+ },
}
err = ciigo.GoEmbed(&genOpts)
diff --git a/embed_options.go b/embed_options.go
index cc722a1..52dae1a 100644
--- a/embed_options.go
+++ b/embed_options.go
@@ -11,19 +11,7 @@ import "github.com/shuLhan/share/lib/memfs"
//
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
+ memfs.EmbedOptions
}
func (opts *EmbedOptions) init() (err error) {
diff --git a/go.mod b/go.mod
index 7ac9283..0167239 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.16
require (
git.sr.ht/~shulhan/asciidoctor-go v0.1.1-0.20211004182124-1c48dfa11a1b
- github.com/shuLhan/share v0.30.1-0.20211009182253-4cee5850bc7f
+ github.com/shuLhan/share v0.30.1-0.20211026162333-a7fd63a0836f
)
//replace git.sr.ht/~shulhan/asciidoctor-go => ../asciidoctor-go
diff --git a/go.sum b/go.sum
index d9156db..0b923f5 100644
--- a/go.sum
+++ b/go.sum
@@ -1,8 +1,8 @@
git.sr.ht/~shulhan/asciidoctor-go v0.1.1-0.20211004182124-1c48dfa11a1b h1:LrKeNE5urwiAZcuv1ACKwStbXpxWIaXNKrL4aCsN2EE=
git.sr.ht/~shulhan/asciidoctor-go v0.1.1-0.20211004182124-1c48dfa11a1b/go.mod h1:fGzLvcEmRkdfo9mg7sp7fQHQHquCUJ4+6nRfWi6I7B0=
github.com/shuLhan/share v0.30.0/go.mod h1:9gv+ID20OrJiXz0y+fZ9e9Ah4CIX2vJVVbcKiI3az5Y=
-github.com/shuLhan/share v0.30.1-0.20211009182253-4cee5850bc7f h1:eqvNnElrkrGcd1hebTj2Cx+FwANMxnOAwOqlER/FtiE=
-github.com/shuLhan/share v0.30.1-0.20211009182253-4cee5850bc7f/go.mod h1:1E7VQSKC7cbCmAi6izvm2S8jH5Z98a9SSS2IlvmNs/Y=
+github.com/shuLhan/share v0.30.1-0.20211026162333-a7fd63a0836f h1:6NhrAx3jJXTsNNnn97RTk2HFjUbR9i2nGBDStAIRwCg=
+github.com/shuLhan/share v0.30.1-0.20211026162333-a7fd63a0836f/go.mod h1:1E7VQSKC7cbCmAi6izvm2S8jH5Z98a9SSS2IlvmNs/Y=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
diff --git a/internal/cmd/goembed/main.go b/internal/cmd/goembed/main.go
index 44ba0fa..368c4ce 100644
--- a/internal/cmd/goembed/main.go
+++ b/internal/cmd/goembed/main.go
@@ -10,6 +10,7 @@ import (
"log"
"git.sr.ht/~shulhan/ciigo"
+ "github.com/shuLhan/share/lib/memfs"
)
func main() {
@@ -18,9 +19,11 @@ func main() {
Root: "_example",
HtmlTemplate: "_example/html.tmpl",
},
- PackageName: "main",
- VarName: "ciigoFS",
- GoFileName: "cmd/ciigo-example/static.go",
+ EmbedOptions: memfs.EmbedOptions{
+ PackageName: "main",
+ VarName: "ciigoFS",
+ GoFileName: "cmd/ciigo-example/static.go",
+ },
}
err := ciigo.GoEmbed(&opts)
if err != nil {