commit | 2db7bbcd0c9b0aa1195a417d29700f366d65a47b | [log] [tgz] |
---|---|---|
author | Taru Karttunen <taruti@taruti.net> | Wed Sep 13 19:37:21 2017 |
committer | Jeremy Stribling <strib@alum.mit.edu> | Mon Nov 27 19:11:07 2017 |
tree | 9475cb9e42445cc08a55f5eedc0c479e5979955a | |
parent | 8a2434ab7c4f9846dd33506612702aacb28d7278 [diff] |
Support extending files in memoryfs truncate
diff --git a/memfs/memory.go b/memfs/memory.go index 1d1a0e2..2f8dcae 100644 --- a/memfs/memory.go +++ b/memfs/memory.go
@@ -273,7 +273,10 @@ func (f *file) Truncate(size int64) error { if size < int64(len(f.content.bytes)) { f.content.bytes = f.content.bytes[:size] + } else if more := int(size)-len(f.content.bytes); more > 0 { + f.content.bytes = append(f.content.bytes, make([]byte, more)...) } + return nil }