Source file
test/fixedbugs/issue13268.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package main
16
17 import (
18 "io/ioutil"
19 "log"
20 "os"
21 "os/exec"
22 "strings"
23 )
24
25 func main() {
26
27 f, err := ioutil.TempFile("", "issue13268-")
28 if err != nil {
29 log.Fatalf("could not create source file: %v", err)
30 }
31 f.Write([]byte("package p\n\nfunc \xef\xef"))
32 f.Close()
33 defer os.Remove(f.Name())
34
35
36 cmd := exec.Command("go", "tool", "compile", f.Name())
37 out, err := cmd.CombinedOutput()
38 if err == nil {
39 log.Fatalf("expected cmd/compile to fail")
40 }
41 if strings.HasPrefix(string(out), "illegal UTF-8 sequence") {
42 log.Fatalf("error %q not found", out)
43 }
44 }
45
View as plain text