github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/go/printer/example_test.go (about) 1 // Copyright 2012 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package printer_test 6 7 func ExampleFprint() { 8 printSelf() 9 10 // Output: 11 // funcAST, fset := parseFunc("example_test.go", "printSelf") 12 // 13 // var buf bytes.Buffer 14 // printer.Fprint(&buf, fset, funcAST.Body) 15 // 16 // s := buf.String() 17 // s = s[1 : len(s)-1] 18 // s = strings.TrimSpace(strings.ReplaceAll(s, "\n\t", "\n")) 19 // 20 // fmt.Println(s) 21 }