pkg: refactor to buf.WriteString() (#3769)
This commit is contained in:
parent
a3e4a41468
commit
ef13067401
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user