Add an example of our CommentStripper that doubles as a test
This commit is contained in:
parent
2b0958eb1b
commit
8e09786a2f
|
|
@ -0,0 +1,31 @@
|
||||||
|
package stripper_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/docker-library/go-dockerlibrary/pkg/stripper"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleCommentStripper() {
|
||||||
|
r := strings.NewReader(`
|
||||||
|
# opening comment
|
||||||
|
a: b
|
||||||
|
# comment!
|
||||||
|
c: d # not a comment
|
||||||
|
|
||||||
|
# another cheeky comment
|
||||||
|
e: f
|
||||||
|
`)
|
||||||
|
|
||||||
|
comStrip := stripper.NewCommentStripper(r)
|
||||||
|
|
||||||
|
io.Copy(os.Stdout, comStrip)
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// a: b
|
||||||
|
// c: d # not a comment
|
||||||
|
//
|
||||||
|
// e: f
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue