Skip to content

Commit

Permalink
Add File.Split
Browse files Browse the repository at this point in the history
  • Loading branch information
nochso committed Nov 12, 2016
1 parent b88863a commit b6bb7b1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions golden.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"os"
"path/filepath"
"regexp"
"strings"
"testing"

Expand Down Expand Up @@ -115,6 +116,13 @@ func (f File) String() string {
return string(f.Bytes())
}

// Split the file into a string slice using separator sep.
func (f File) Split(sep string) []string {
pat := fmt.Sprintf("\n{0,1}%s\n{0,1}", regexp.QuoteMeta(sep))
re := regexp.MustCompile(pat)
return re.Split(f.String(), -1)
}

func (f File) Exists() bool {
_, err := os.Stat(f.Path)
return err == nil
Expand Down

0 comments on commit b6bb7b1

Please sign in to comment.