headtail

package module
v0.0.0-...-9f7a764 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

README

head-tail

Documentation

Overview

Example (Head)
package main

import (
	"fmt"
	"log"

	headtail "github.com/sbleks/head-tail"
)

func main() {

	lines, err := headtail.Head(`testdata/somefile`, 3)
	if err != nil {
		log.Panicln(err)
	}
	fmt.Println(lines)

}
Output:

[alpha beta gamma]
Example (Head_over_limit)
package main

import (
	"fmt"
	"log"

	headtail "github.com/sbleks/head-tail"
)

func main() {

	lines, err := headtail.Head(`testdata/somefile`, 100)
	if err != nil {
		log.Panicln(err)
	}
	fmt.Println(lines)

}
Output:

[alpha beta gamma delta]
Example (Tail)
package main

import (
	"fmt"
	"log"

	headtail "github.com/sbleks/head-tail"
)

func main() {

	lines, err := headtail.Tail(`testdata/somefile`, 3)
	if err != nil {
		log.Panicln(err)
	}
	fmt.Println(lines)

}
Output:

[beta gamma delta]
Example (Tail_over_limit)
package main

import (
	"fmt"
	"log"

	headtail "github.com/sbleks/head-tail"
)

func main() {

	lines, err := headtail.Tail(`testdata/somefile`, 100)
	if err != nil {
		log.Panicln(err)
	}
	fmt.Println(lines)

}
Output:

[alpha beta gamma delta]

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Head(path string, n int) ([]string, error)

Head returns the top n lines of a file like the UNIX command.

func Tail

func Tail(path string, n int) ([]string, error)

Tail returns the bottom n lines of a file like the UNIX command.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL