Skip to content

Commit

Permalink
pkg: refactor to buf.WriteString() (#3769)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Jul 11, 2024
1 parent a3e4a41 commit ef13067
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions _scripts/gen-faq-toc.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func spliceDocs(docpath string, docs []byte, outpath string) {
footer := v[1]

outbuf := bytes.NewBuffer(make([]byte, 0, len(header)+len(docs)+len(footer)+len(startOfToc)+len(endOfToc)+1))
outbuf.Write([]byte(header))
outbuf.Write([]byte(startOfToc))
outbuf.WriteString(header)
outbuf.WriteString(startOfToc)
outbuf.WriteByte('\n')
outbuf.Write(docs)
outbuf.Write([]byte(endOfToc))
outbuf.Write([]byte(footer))
outbuf.WriteString(endOfToc)
outbuf.WriteString(footer)

if outpath != "-" {
err = os.WriteFile(outpath, outbuf.Bytes(), 0o664)
Expand Down
2 changes: 1 addition & 1 deletion pkg/dwarf/dwarfbuilder/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (b *Builder) Attr(attr dwarf.Attr, val interface{}) dwarf.Offset {
switch x := val.(type) {
case string:
tag.form = append(tag.form, DW_FORM_string)
b.info.Write([]byte(x))
b.info.WriteString(x)
b.info.WriteByte(0)
case uint8:
tag.form = append(tag.form, DW_FORM_data1)
Expand Down
2 changes: 1 addition & 1 deletion pkg/proc/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (t *Target) dumpThreadNotes(notes []elfwriter.Note, state *DumpState, th Th

for _, reg := range regsv {
binary.Write(buf, binary.LittleEndian, uint16(len(reg.Name)))
buf.Write([]byte(reg.Name))
buf.WriteString(reg.Name)
if reg.Reg.Bytes != nil {
binary.Write(buf, binary.LittleEndian, uint16(len(reg.Reg.Bytes)))
buf.Write(reg.Reg.Bytes)
Expand Down
2 changes: 1 addition & 1 deletion pkg/proc/gdbserial/rr.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func rrStderrParser(stderr io.ReadCloser, initch chan<- rrInit, quiet bool) {
}

if !quiet {
os.Stderr.Write([]byte(line))
os.Stderr.WriteString(line)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/terminal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3127,7 +3127,7 @@ func (c *Commands) onCmd(t *Term, ctx callContext, argstr string) error {
_ = os.Remove(f.Name())
}()
attrs := formatBreakpointAttrs("", ctx.Breakpoint, true)
_, err = f.Write([]byte(strings.Join(attrs, "\n")))
_, err = f.WriteString(strings.Join(attrs, "\n"))
if err != nil {
return err
}
Expand Down

0 comments on commit ef13067

Please sign in to comment.