pingcap/go-ycsb

Build error: `buf.WriteString` becomes undefined after `buf *bytes.Buffer` was replaced by `buf []byte`

94rain opened this issue · 0 comments

Description:
I see that after #181 was merged, the project no longer compiles due to the following errors (in github actions)

image

All methods of buf (including buf.WriteString, buf.WriteByte) becomes undefined after buf *bytes.Buffer was replaced by buf []byte (data type change).

Possible solution:
A potential fix for WriteString could be (needs '...' as suffix for appending string to bytes[])

- buf.WriteString(fmt.Sprintf(`SELECT * FROM %s %s WHERE YCSB_KEY IN (`, table, db.forceIndexKeyword))
+ buf = append(buf, fmt.Sprintf(`SELECT * FROM %s %s WHERE YCSB_KEY IN (`, table, db.forceIndexKeyword)...)

A fix for WriteByte could be

- buf.WriteByte('?')
+ buf = append(buf, '?')

I am not sure if there are better ways. There are plenty of them that need to be fixed (much more than what is displayed).