Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var MediaTypes = []string{
"application/x-bzip2",
"application/x-gzip",
"application/x-zstd",
"application/x-snappy-framed",
"text/plain; charset=utf-8",
}
MediaTypes natively supported by the bufio scanner.
Functions ¶
func NewScanner ¶
func NewScanner() *scanner
NewScanner returns a new
Example (ReadFile) ¶
package main
import (
"fmt"
"os"
"github.com/brexhq/substation/internal/bufio"
)
func main() {
// temp file is used to simulate an open file and must be removed after the test completes
file, _ := os.CreateTemp("", "substation")
defer os.Remove(file.Name())
_, _ = file.Write([]byte("foo\nbar\nbaz"))
// scanner closes all open handles, including the open file
s := bufio.NewScanner()
defer s.Close()
// scanner automatically decompresses file and chooses appropriate scan method (default is "text")
if err := s.ReadFile(file); err != nil {
// handle error
panic(err)
}
for s.Scan() {
fmt.Println(s.Text())
}
if err := s.Err(); err != nil {
// handle error
panic(err)
}
}
Output: foo bar baz
Example (Setup) ¶
package main
import (
"github.com/brexhq/substation/internal/bufio"
)
func main() {
s := bufio.NewScanner()
defer s.Close()
}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.