1
0
mirror of https://github.com/golang/go synced 2024-11-24 04:30:14 -07:00

net/smtp: use strings.Builder

Change-Id: I0d1195fcb4eceb12c4be3190b05a82079dc496a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/428272
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
cuiweixie 2022-09-04 18:41:58 +08:00 committed by Benny Siegert
parent 6a2ff105f1
commit e2d8ed2fd7

View File

@ -113,7 +113,7 @@ func TestAuthPlain(t *testing.T) {
func TestClientAuthTrimSpace(t *testing.T) {
server := "220 hello world\r\n" +
"200 some more"
var wrote bytes.Buffer
var wrote strings.Builder
var fake faker
fake.ReadWriter = struct {
io.Reader
@ -164,7 +164,7 @@ func TestBasic(t *testing.T) {
server := strings.Join(strings.Split(basicServer, "\n"), "\r\n")
client := strings.Join(strings.Split(basicClient, "\n"), "\r\n")
var cmdbuf bytes.Buffer
var cmdbuf strings.Builder
bcmdbuf := bufio.NewWriter(&cmdbuf)
var fake faker
fake.ReadWriter = bufio.NewReadWriter(bufio.NewReader(strings.NewReader(server)), bcmdbuf)
@ -505,7 +505,7 @@ func TestNewClient(t *testing.T) {
server := strings.Join(strings.Split(newClientServer, "\n"), "\r\n")
client := strings.Join(strings.Split(newClientClient, "\n"), "\r\n")
var cmdbuf bytes.Buffer
var cmdbuf strings.Builder
bcmdbuf := bufio.NewWriter(&cmdbuf)
out := func() string {
bcmdbuf.Flush()
@ -550,7 +550,7 @@ func TestNewClient2(t *testing.T) {
server := strings.Join(strings.Split(newClient2Server, "\n"), "\r\n")
client := strings.Join(strings.Split(newClient2Client, "\n"), "\r\n")
var cmdbuf bytes.Buffer
var cmdbuf strings.Builder
bcmdbuf := bufio.NewWriter(&cmdbuf)
var fake faker
fake.ReadWriter = bufio.NewReadWriter(bufio.NewReader(strings.NewReader(server)), bcmdbuf)
@ -643,7 +643,7 @@ func TestHello(t *testing.T) {
for i := 0; i < len(helloServer); i++ {
server := strings.Join(strings.Split(baseHelloServer+helloServer[i], "\n"), "\r\n")
client := strings.Join(strings.Split(baseHelloClient+helloClient[i], "\n"), "\r\n")
var cmdbuf bytes.Buffer
var cmdbuf strings.Builder
bcmdbuf := bufio.NewWriter(&cmdbuf)
var fake faker
fake.ReadWriter = bufio.NewReadWriter(bufio.NewReader(strings.NewReader(server)), bcmdbuf)
@ -749,7 +749,7 @@ var helloClient = []string{
func TestSendMail(t *testing.T) {
server := strings.Join(strings.Split(sendMailServer, "\n"), "\r\n")
client := strings.Join(strings.Split(sendMailClient, "\n"), "\r\n")
var cmdbuf bytes.Buffer
var cmdbuf strings.Builder
bcmdbuf := bufio.NewWriter(&cmdbuf)
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
@ -906,7 +906,7 @@ SendMail is working for me.
func TestAuthFailed(t *testing.T) {
server := strings.Join(strings.Split(authFailedServer, "\n"), "\r\n")
client := strings.Join(strings.Split(authFailedClient, "\n"), "\r\n")
var cmdbuf bytes.Buffer
var cmdbuf strings.Builder
bcmdbuf := bufio.NewWriter(&cmdbuf)
var fake faker
fake.ReadWriter = bufio.NewReadWriter(bufio.NewReader(strings.NewReader(server)), bcmdbuf)