9
[Golang] Read Lines From File or String
source link: http://siongui.github.io/2016/04/06/go-readlines-from-file-or-string/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Readlines From String
import ( "bufio" "strings" ) func StringToLines(s string) (lines []string, err error) { scanner := bufio.NewScanner(strings.NewReader(s)) for scanner.Scan() { lines = append(lines, scanner.Text()) } err = scanner.Err() return }
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK