Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
use different param for Read
Browse files Browse the repository at this point in the history
  • Loading branch information
fayez-marble committed Jul 7, 2022
1 parent c75253f commit 06cc211
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/wrapper/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,15 @@ func (g *generator) generateReader(
}

var tpl = `
func ({{.Receiver}} {{.WrapperStruct}}) Read(p []byte) (int, error) {
func ({{.Receiver}} {{.WrapperStruct}}) Read(buff []byte) (int, error) {
` +
lockingCode + // inject locking code
`{{.Receiver}}.DataType = "{{.Struct}}"
data, err := json.Marshal({{.Receiver}})
if err != nil {
return 0, err
}
n := copy(p, data)
n := copy(buff, data)
return n, nil
}`

Expand All @@ -281,11 +281,11 @@ func (g *generator) generateStruct(
) (string, error) {
var datatype string
if g.reader {
datatype = `// The name of the original type, it gets initalized when calling Read() function, DO NOT USE IT
datatype = `// The name of the original type, it gets initialized when calling Read() function, DO NOT USE IT
DataType string ` + "`json:\"_data_type,omitempty\"`"
}
var tpl = `
// {{.WrapperStruct}} encapulates the type {{.Struct}}
// {{.WrapperStruct}} encapsulates the type {{.Struct}}
type {{.WrapperStruct}} struct {
` + datatype + `
{{.Struct}}
Expand Down

0 comments on commit 06cc211

Please sign in to comment.