This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e20b63a
commit 3ea9b38
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
cmd/testdata/.snapshots/TestExecute-GetterAndInterfaceAndReader.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package test | ||
|
||
import ( | ||
"encoding/json" | ||
"io" | ||
) | ||
|
||
type ITester interface { | ||
Field1() string | ||
SetField1(val string) | ||
GetSecondField() int32 | ||
Read(p []byte) (int, error) | ||
} | ||
|
||
// TesterWrapper encapulates the type Tester | ||
type TesterWrapper struct { | ||
// The name of the original type, it gets initalized when calling Read() function, DO NOT USE IT | ||
DataType string `json:"_data_type,omitempty"` | ||
Tester | ||
} | ||
|
||
func (t TesterWrapper) Field1() string { | ||
return t.Tester.Field1 | ||
} | ||
|
||
func (t TesterWrapper) SetField1(val string) { | ||
t.Tester.Field1 = val | ||
} | ||
|
||
func (t TesterWrapper) GetSecondField() int32 | ||
return t.Tester.Field2 | ||
} | ||
|
||
func (t TesterWrapper) Read(p []byte) (int, error) { | ||
t.DataType = "Tester" | ||
data, err := json.Marshal(t) | ||
if err != nil { | ||
return 0, err | ||
} | ||
n := copy(p, data) | ||
return n, nil | ||
} |