Skip to content

Commit

Permalink
update examples (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
pomdtr authored Feb 26, 2023
1 parent 14f5d16 commit ad37568
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
9 changes: 4 additions & 5 deletions examples/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"log"
"os"

"github.com/leaanthony/gosod"
)
Expand All @@ -11,20 +12,18 @@ type config struct {
}

func main() {
fs := os.DirFS("./myTemplate")

// Define a new Template directory
basic, err := gosod.TemplateDir("./myTemplate")
if err != nil {
log.Fatal(err)
}
basic := gosod.New(fs)

// Make some config data
myConfig := &config{
Name: "Mat",
}

// Create a new directory using the template and config
err = basic.Extract("./generated", myConfig)
err := basic.Extract("./generated", myConfig)
if err != nil {
log.Fatal(err)
}
Expand Down
9 changes: 4 additions & 5 deletions examples/filters/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"log"
"os"

"github.com/leaanthony/gosod"
)
Expand All @@ -11,12 +12,10 @@ type config struct {
}

func main() {
fs := os.DirFS("./myTemplate")

// Define a new Template directory
basic, err := gosod.TemplateDir("./myTemplate")
if err != nil {
log.Fatal(err)
}
basic := gosod.New(fs)

// Register the filename to ignore
basic.SetTemplateFilters([]string{".template", ".tmpl"})
Expand All @@ -27,7 +26,7 @@ func main() {
}

// Create a new directory using the template and config
err = basic.Extract("./generated", myConfig)
err := basic.Extract("./generated", myConfig)
if err != nil {
log.Fatal(err)
}
Expand Down
11 changes: 5 additions & 6 deletions examples/ignore/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"log"
"os"

"github.com/leaanthony/gosod"
)
Expand All @@ -11,23 +12,21 @@ type config struct {
}

func main() {
fs := os.DirFS("./myTemplate")

// Define a new Template directory
basic, err := gosod.TemplateDir("./myTemplate")
if err != nil {
log.Fatal(err)
}
basic := gosod.New(fs)

// Register the filename to ignore
basic.IgnoreFilename("ignore.txt")
basic.IgnoreFile("ignore.txt")

// Make some config data
myConfig := &config{
Name: "Mat",
}

// Create a new directory using the template and config
err = basic.Extract("./generated", myConfig)
err := basic.Extract("./generated", myConfig)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit ad37568

Please sign in to comment.