1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
// Copyright (c) 2014-2019 TSUYUSATO Kitsune
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
package heredoc_test
import (
"fmt"
)
import "github.com/MakeNowJust/heredoc"
func ExampleDoc_lipsum() {
fmt.Print(heredoc.Doc(`
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, ...
`))
// Output:
// Lorem ipsum dolor sit amet, consectetur adipisicing elit,
// sed do eiusmod tempor incididunt ut labore et dolore magna
// aliqua. Ut enim ad minim veniam, ...
//
}
func ExampleDoc_spec() {
// Single line string is no change.
fmt.Println(heredoc.Doc(`It is single line.`))
// If first line is empty, heredoc.Doc removes first line.
fmt.Println(heredoc.Doc(`
It is first line.
It is second line.`))
// If last line is empty and more little length than indents,
// heredoc.Doc removes last line's content.
fmt.Println(heredoc.Doc(`
Next is last line.
`))
fmt.Println("Previous is last line.")
// Output:
// It is single line.
// It is first line.
// It is second line.
// Next is last line.
//
// Previous is last line.
}
func ExampleDocf() {
libName := "github.com/MakeNowJust/heredoc"
author := "TSUYUSATO Kitsune (@MakeNowJust)"
fmt.Printf(heredoc.Docf(`
Library Name : %s
Author : %s
Repository URL: http://%s.git
`, libName, author, libName))
// Output:
// Library Name : github.com/MakeNowJust/heredoc
// Author : TSUYUSATO Kitsune (@MakeNowJust)
// Repository URL: http://github.com/MakeNowJust/heredoc.git
}
|