mirror of
https://github.com/golang/go
synced 2024-11-21 14:04:41 -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:
parent
acc82ad721
commit
2a81292ac3
@ -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
|
||||
b.WriteTo(os.Stdout)
|
||||
if *html {
|
||||
template.HTMLEscape(os.Stdout, b.Bytes())
|
||||
} else {
|
||||
b.WriteTo(os.Stdout)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user