Skip to content

Commit d5b5f75

Browse files
authored
Merge pull request #5 from infosiftr/stripper-example-test
Add an example of our CommentStripper that doubles a test
2 parents 2b0958e + 8e09786 commit d5b5f75

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

pkg/stripper/comments_example_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package stripper_test
2+
3+
import (
4+
"io"
5+
"os"
6+
"strings"
7+
8+
"github.com/docker-library/go-dockerlibrary/pkg/stripper"
9+
)
10+
11+
func ExampleCommentStripper() {
12+
r := strings.NewReader(`
13+
# opening comment
14+
a: b
15+
# comment!
16+
c: d # not a comment
17+
18+
# another cheeky comment
19+
e: f
20+
`)
21+
22+
comStrip := stripper.NewCommentStripper(r)
23+
24+
io.Copy(os.Stdout, comStrip)
25+
26+
// Output:
27+
// a: b
28+
// c: d # not a comment
29+
//
30+
// e: f
31+
}

0 commit comments

Comments
 (0)