1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:04:42 -07:00

net: use strings.Builder

Change-Id: I3861a73d6b9d1d454c42bec50099b916bf30f1cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/428266
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
cuiweixie 2022-09-04 18:17:40 +08:00 committed by Robert Griesemer
parent 29af494fca
commit 8fd2073694
2 changed files with 5 additions and 7 deletions

View File

@ -7,7 +7,6 @@
package net
import (
"bytes"
"context"
"fmt"
"internal/testenv"
@ -718,7 +717,7 @@ func testDots(t *testing.T, mode string) {
}
func mxString(mxs []*MX) string {
var buf bytes.Buffer
var buf strings.Builder
sep := ""
fmt.Fprintf(&buf, "[")
for _, mx := range mxs {
@ -730,7 +729,7 @@ func mxString(mxs []*MX) string {
}
func nsString(nss []*NS) string {
var buf bytes.Buffer
var buf strings.Builder
sep := ""
fmt.Fprintf(&buf, "[")
for _, ns := range nss {
@ -742,7 +741,7 @@ func nsString(nss []*NS) string {
}
func srvString(srvs []*SRV) string {
var buf bytes.Buffer
var buf strings.Builder
sep := ""
fmt.Fprintf(&buf, "[")
for _, srv := range srvs {

View File

@ -5,7 +5,6 @@
package net
import (
"bytes"
"context"
"encoding/json"
"errors"
@ -216,8 +215,8 @@ func (s byHost) Less(i, j int) bool { return s[i].Host < s[j].Host }
func (s byHost) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func nslookup(qtype, name string) (string, error) {
var out bytes.Buffer
var err bytes.Buffer
var out strings.Builder
var err strings.Builder
cmd := exec.Command("nslookup", "-querytype="+qtype, name)
cmd.Stdout = &out
cmd.Stderr = &err