aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ciigo.go28
-rw-r--r--ciigo_test.go2
-rw-r--r--cmd/ciigo-example/main.go4
-rw-r--r--cmd/ciigo/main.go6
4 files changed, 14 insertions, 26 deletions
diff --git a/ciigo.go b/ciigo.go
index 01e11cf..3ba0822 100644
--- a/ciigo.go
+++ b/ciigo.go
@@ -52,12 +52,9 @@ type Ciigo struct {
// files using ConvertOptions HTMLTemplate file as base template.
// If HTMLTemplate is empty it will default to use embedded HTML template.
// See template_index_html.go for template format.
-func Convert(opts *ConvertOptions) (err error) {
- if opts == nil {
- opts = &ConvertOptions{}
- }
+func Convert(opts ConvertOptions) (err error) {
var ciigo = &Ciigo{}
- return ciigo.Convert(*opts)
+ return ciigo.Convert(opts)
}
// GoEmbed generate a static Go file that embed all files inside Root except
@@ -70,22 +67,16 @@ func Convert(opts *ConvertOptions) (err error) {
// If HTMLTemplate option is empty it default to use embedded HTML
// template.
// See template_index_html.go for template format.
-func GoEmbed(opts *EmbedOptions) (err error) {
- if opts == nil {
- opts = &EmbedOptions{}
- }
+func GoEmbed(opts EmbedOptions) (err error) {
var ciigo = &Ciigo{}
- return ciigo.GoEmbed(*opts)
+ return ciigo.GoEmbed(opts)
}
// Serve the content under directory "[ServeOptions].ConvertOptions.Root"
// using HTTP server at specific "[ServeOptions].Address".
-func Serve(opts *ServeOptions) (err error) {
- if opts == nil {
- opts = &ServeOptions{}
- }
+func Serve(opts ServeOptions) (err error) {
var ciigo = &Ciigo{}
- err = ciigo.InitHTTPServer(*opts)
+ err = ciigo.InitHTTPServer(opts)
if err != nil {
return err
}
@@ -100,12 +91,9 @@ func Serve(opts *ServeOptions) (err error) {
// If the HTML template file modified, it will re-convert all markup files.
// If the HTML template file deleted, it will replace them with internal,
// default HTML template.
-func Watch(opts *ConvertOptions) (err error) {
- if opts == nil {
- opts = &ConvertOptions{}
- }
+func Watch(opts ConvertOptions) (err error) {
var ciigo = &Ciigo{}
- return ciigo.Watch(*opts)
+ return ciigo.Watch(opts)
}
// isHTMLTemplateNewer will return true if HTMLTemplate is not defined or
diff --git a/ciigo_test.go b/ciigo_test.go
index 1484ce2..3b3f5de 100644
--- a/ciigo_test.go
+++ b/ciigo_test.go
@@ -123,7 +123,7 @@ func TestGoEmbed(t *testing.T) {
fpath = filepath.Join(outDir, fname)
tcase.opts.EmbedOptions.GoFileName = filepath.Join(outDir, fname)
- err = GoEmbed(&tcase.opts)
+ err = GoEmbed(tcase.opts)
if err != nil {
t.Fatal(err)
}
diff --git a/cmd/ciigo-example/main.go b/cmd/ciigo-example/main.go
index 5c563aa..a96a53d 100644
--- a/cmd/ciigo-example/main.go
+++ b/cmd/ciigo-example/main.go
@@ -23,7 +23,7 @@ var ciigoFS *memfs.MemFS
func main() {
var (
- opts = &ciigo.ServeOptions{
+ opts = ciigo.ServeOptions{
ConvertOptions: ciigo.ConvertOptions{
Root: "_example",
HTMLTemplate: "_example/html.tmpl",
@@ -71,7 +71,7 @@ func doEmbed() {
err error
)
- err = ciigo.GoEmbed(&opts)
+ err = ciigo.GoEmbed(opts)
if err != nil {
log.Fatal(err)
}
diff --git a/cmd/ciigo/main.go b/cmd/ciigo/main.go
index d4d4fc9..a4b734c 100644
--- a/cmd/ciigo/main.go
+++ b/cmd/ciigo/main.go
@@ -67,7 +67,7 @@ func main() {
switch command {
case cmdConvert:
- err = ciigo.Convert(&convertOpts)
+ err = ciigo.Convert(convertOpts)
case cmdEmbed:
var embedOpts = ciigo.EmbedOptions{
@@ -79,7 +79,7 @@ func main() {
},
}
- err = ciigo.GoEmbed(&embedOpts)
+ err = ciigo.GoEmbed(embedOpts)
case cmdHelp:
usage()
@@ -91,7 +91,7 @@ func main() {
EnableIndexHTML: true,
IsDevelopment: true,
}
- err = ciigo.Serve(&serveOpts)
+ err = ciigo.Serve(serveOpts)
case cmdVersion:
fmt.Println(ciigo.Version)