We use the [fs](http://godoc.org/github.com/globocom/gandalf/fs) to mock out the filesystem. You can use a recording file system in tests (have a look: https://github.com/globocom/gandalf/blob/master/repository/repository_test.go#L136).

And the production code could look something like:

```go
file, err := fs.Fsystem.Create(scriptPath)
if err != nil {
  return err
}
defer file.Close()
io.Copy(file, body)
```