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

log: Output() does not append a newline if the string is empty #9665

Closed
nerdatmath opened this issue Jan 22, 2015 · 0 comments
Closed

log: Output() does not append a newline if the string is empty #9665

nerdatmath opened this issue Jan 22, 2015 · 0 comments
Milestone

Comments

@nerdatmath
Copy link
Contributor

Go version: 1.3 and up to current tip

Running the following program results in a single output line with two log headers (http://play.golang.org/p/e0CHv4tdQi):

package main
import "log"
func main() {
    log.Print("")
    log.Println("<- two headers")
}

I believe this line in log/log.go (Logger.Output):

     if len(s) > 0 && s[len(s)-1] != '\n' {

Should be changed to read:

     if len(s) == 0 || s[len(s)-1] != '\n' {

Thank you for your consideration.

@bradfitz bradfitz added this to the Go1.5 milestone Jan 22, 2015
@robpike robpike closed this as completed in d340b10 Apr 9, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
@rsc rsc unassigned robpike Jun 23, 2022
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

4 participants