1
0
mirror of https://github.com/golang/go synced 2024-11-13 18:10:24 -07:00

srcextract: HTML-escape output if so desired

This functionality was removed with CL 4169041.

Minor simplifications.

R=r, adg
CC=golang-dev
https://golang.org/cl/4171042
This commit is contained in:
Robert Griesemer 2011-02-09 14:08:19 -08:00
parent acc82ad721
commit 2a81292ac3

View File

@ -9,6 +9,7 @@ import (
"go/token"
"log"
"os"
"template"
)
var (
@ -31,11 +32,6 @@ func main() {
if err != nil {
log.Fatal(err)
}
// create printer
p := &printer.Config{
Mode: 0,
Tabwidth: 8,
}
// create filter
filter := func(name string) bool {
return name == *getName
@ -44,8 +40,9 @@ func main() {
if !ast.FilterFile(file, filter) {
os.Exit(1)
}
b := new(bytes.Buffer)
p.Fprint(b, fs, file)
// print the AST
var b bytes.Buffer
printer.Fprint(&b, fs, file)
// drop package declaration
if !*showPkg {
for {
@ -67,5 +64,9 @@ func main() {
}
}
// output
if *html {
template.HTMLEscape(os.Stdout, b.Bytes())
} else {
b.WriteTo(os.Stdout)
}
}