Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/textproto: Add support for multi-line Error #6009

Closed
gopherbot opened this issue Aug 1, 2013 · 3 comments
Closed

net/textproto: Add support for multi-line Error #6009

gopherbot opened this issue Aug 1, 2013 · 3 comments
Milestone

Comments

@gopherbot
Copy link

by ruizh.cj:

When trying to send a multi-line response, func (e *Error) Error() string should use the
separator "-" instead of " " in all lines but the last, in
compliance with text-based protocols such as SMTP.

Given the following snippet:
err := textproto.Error{Code: 250, Msg: "localhost at your
service.\nSTARTTLS\n8BITMIME"
fmt.Println(err.Error())

What is the expected output?
250-localhost at your service.
250-STARTTLS
250 8BITMIME

What do you see instead?
250 localhost at your service.
STARTTLS
8BITMIME

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
linux_amd64

Which version are you using?  (run 'go version')
go version go1.1.1 linux/amd64

Please provide any additional information below.
I provide a patch with an example implementation.

Attachments:

  1. multilineError.diff (790 bytes)
@robpike
Copy link
Contributor

robpike commented Aug 2, 2013

Comment 1:

Don't put newlines in your errors and they won't cause trouble.

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Author

Comment 2 by ruizh.cj:

The behavior I explain is useful sometimes (e.g. the EHLO response in SMTP,
where the server must print each extension in a new line) and it's much
easier and readable to have the method manage it by itself instead of
having to define a helper function.
El 02/08/2013 07:57, <go@googlecode.com> escribi�

@rsc
Copy link
Contributor

rsc commented Aug 2, 2013

Comment 3:

The string returned by Error is for people, not programs.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants