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

fmt: Go tip %q generates a Go string not readable by Go 1.0.3? #4346

Closed
bradfitz opened this issue Nov 5, 2012 · 4 comments
Closed

fmt: Go tip %q generates a Go string not readable by Go 1.0.3? #4346

bradfitz opened this issue Nov 5, 2012 · 4 comments
Milestone

Comments

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Nov 5, 2012

I generated a Go program that embeds a PNG file in a Go program using:

b, err := ioutil.ReadAll("foo.png")
...
fmt.Fprintf(f, "... %q ... ")

And it compiled file in Go 1.1.

My friend, compiling with Go 1.0.3, got compilation errors, about invalid code points:

0xdde1
0xddcb
0xdd0c

The PNG files in question are attached.

I ended up working around the problem by not using fmt's %q and just doing the quoted
string construction by hand.

Is this a bug?  (filing at least before I forget)

Attachments:

  1. folder.png (3799 bytes)
  2. node.png (4062 bytes)
@rsc
Copy link
Contributor

@rsc rsc commented Nov 5, 2012

Comment 1:

It's hard to say without an example narrowing down the problem.
There have been some changes involving what code points we accept when, and also with
what we quote and how.

Labels changed: added priority-later, removed priority-triage.

Status changed to WaitingForReply.

@remyoudompheng
Copy link
Contributor

@remyoudompheng remyoudompheng commented Nov 5, 2012

Comment 2:

I have run
package main
import "fmt"
import "io/ioutil"
func main() {
      s, _ := ioutil.ReadFile("/tmp/node.png")
      fmt.Printf("package main\nconst s = %q\n", s)
}
on both images and the result was a compilable Go source file (with Go 1.0.3) in each
case.
@bradfitz
Copy link
Contributor Author

@bradfitz bradfitz commented Nov 6, 2012

Comment 3:

Yeah, I can't reproduce either.  I think it was the go tool (go/parser) as part of "go
build" and +build scanning that was failing, not 6g.  gofmt was also failing to reformat
it, suggesting the same.
But I can't reproduce that either.
But I saw it and worked around it, so I'll try more.
@bradfitz
Copy link
Contributor Author

@bradfitz bradfitz commented Nov 26, 2012

Comment 4:

Who knows.  Closing, since I don't have time to figure out how this happened.

Status changed to Retracted.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.