go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/fileutil/path.go (about) 1 /* 2 3 Copyright (c) 2024 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package fileutil 9 10 import "strings" 11 12 // Path is a utility for handling files. 13 type Path string 14 15 // SplitLines splits an input file by lines. 16 func (p Path) SplitLines() (output []string) { 17 _ = ReadLines(string(p), func(line string) error { 18 output = append(output, line) 19 return nil 20 }) 21 return 22 } 23 24 // SplitWords splits an input file by word boundaries. 25 func (p Path) SplitWords() (output []string) { 26 _ = ReadLines(string(p), func(line string) error { 27 fields := strings.Fields(line) 28 output = append(output, fields...) 29 return nil 30 }) 31 return 32 }