You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
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.
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.
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.
Attachments:
The text was updated successfully, but these errors were encountered: