Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountLines ¶
CountLines counts the number of lines that contains a line break (LF) in a file.
Example ¶
package main import ( "fmt" "log" "strings" "github.com/KEINOS/go-countline/cl" ) func main() { for _, sample := range []struct { Input string }{ {""}, // --> 0 {"Hello"}, // --> 1 {"Hello\n"}, // --> 1 {"\n"}, // --> 1 {"\n\n"}, // --> 2 {"\nHello"}, // --> 2 {"\nHello\n"}, // --> 2 {"\n\nHello"}, // --> 3 {"\n\nHello\n"}, // --> 3 } { readerFile := strings.NewReader(sample.Input) count, err := cl.CountLines(readerFile) if err != nil { log.Fatal(err) } fmt.Printf("%#v --> %v\n", sample.Input, count) } }
Output: "" --> 0 "Hello" --> 1 "Hello\n" --> 1 "\n" --> 1 "\n\n" --> 2 "\nHello" --> 2 "\nHello\n" --> 2 "\n\nHello" --> 3 "\n\nHello\n" --> 3
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
This creates a file of 1 GiB in size with lines of random values.
|
This creates a file of 1 GiB in size with lines of random values. |
Package spec provides the test specifications for the CountLines function.
|
Package spec provides the test specifications for the CountLines function. |
Click to show internal directories.
Click to hide internal directories.