Make sure File is an io.WriterTo
This commit is contained in:
parent
81bd635b09
commit
0ebf3ff4cc
@ -13,6 +13,8 @@ type line any
|
|||||||
type comment string
|
type comment string
|
||||||
type entry struct { key string; value Value }
|
type entry struct { key string; value Value }
|
||||||
|
|
||||||
|
var _ io.WriterTo = new(File)
|
||||||
|
|
||||||
// File represents a config file. It preserves the order of the lines, as well
|
// File represents a config file. It preserves the order of the lines, as well
|
||||||
// as blank lines and comments.
|
// as blank lines and comments.
|
||||||
type File struct {
|
type File struct {
|
||||||
@ -251,8 +253,8 @@ func (this *File) Diff (other *File) map[string] struct { } {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WriteTo writes the data in this file to an io.Writer.
|
// WriteTo writes the data in this file to an io.Writer.
|
||||||
func (file *File) WriteTo (writer io.Writer) (n int64, err error) {
|
func (this *File) WriteTo (writer io.Writer) (n int64, err error) {
|
||||||
for _, lin := range file.lines {
|
for _, lin := range this.lines {
|
||||||
nint := 0
|
nint := 0
|
||||||
switch lin := lin.(type) {
|
switch lin := lin.(type) {
|
||||||
case comment:
|
case comment:
|
||||||
|
Loading…
Reference in New Issue
Block a user