Skip to content

Commit

Permalink
fix: update docs and remove logs
Browse files Browse the repository at this point in the history
  • Loading branch information
h4ckm03d committed Jan 20, 2023
1 parent 16c0bca commit a95127c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,36 +56,32 @@ optgen -file thing.go -name Thing
Output:

```go
// Option is a Thing configurator to be supplied to NewThing() function.
type Option func(*Thing)
// NewThing returns a *Thing.
func NewThing(opt ...func(*Thing)) *Thing {


// NewThing returns a new Thing.
func NewThing(options ...Option) (*Thing, error) {

// Prepare a Thing with default host.
// Prepare a Thing
thing := &Thing{}

// Apply options.
for _, option := range options {
option(thing)
for _, o := range opt {
o(thing)
}

// Do anything here

return thing, nil
return thing
}


// SetField1 sets the Field1
func SetField1(field1 string) Option {
func SetField1(field1 string) func(*Thing) {
return func(c *Thing) {
c.Field1 = field1
}
}

// SetField2 sets the Field2
func SetField2(field2 []*int) Option {
func SetField2(field2 []*int) func(*Thing) {
return func(c *Thing) {
c.Field2 = field2
}
Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func main() {

tmpl := template.Must(template.New("generator").Funcs(funcMap).Parse(generator.CodeTemplate))
var buf bytes.Buffer
fmt.Println(tags, structName)
if err := tmpl.Execute(&buf, TemplateData{
Tags: tags,
StructName: structName,
Expand Down

0 comments on commit a95127c

Please sign in to comment.