Skip to content

Commit 8d81804

Browse files
authored
Fix Base64Bytes sql.Scanner (#307)
1 parent 8958f9d commit 8d81804

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

base64.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ func (b64 *Base64Bytes) Scan(src interface{}) error {
5858
case string:
5959
return b64.Decode(v)
6060
case []byte:
61-
new := append(Base64Bytes{}, v...)
62-
b64 = &new
61+
*b64 = append(Base64Bytes{}, v...)
6362
return nil
6463
case RawJSON:
6564
return b64.UnmarshalJSON(v)

base64_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func TestScanBase64(t *testing.T) {
157157

158158
inputStr := "VGhpcyBpcyBhIHRlc3Qgc3RyaW5n"
159159
inputJSON := RawJSON(`"` + inputStr + `"`)
160-
inputBytes := []byte(inputStr)
160+
inputBytes := []byte(expecting)
161161
inputInt := 3
162162

163163
var b Base64Bytes

0 commit comments

Comments
 (0)