text

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(filename, originalFileContent, newFileContent string) string

Diff return a diff like string, comparing string A and string B

func IsURL

func IsURL(location string) bool

IsURL tests if a string is a valid http URL

func Show

func Show(content string) (result string)

Show return a string where each line start with a tabulation to increase visibility

Types

type MockTextRetriever added in v0.13.0

type MockTextRetriever struct {
	Err      error
	Contents map[string]string
}

MockTextRetriever is a stub implementation of the `TextRetriever` interface to be used in our unit test suites. It stores the expected Content and Err

func (*MockTextRetriever) FileExists added in v0.13.0

func (mtr *MockTextRetriever) FileExists(location string) bool

func (*MockTextRetriever) ReadAll added in v0.13.0

func (mtr *MockTextRetriever) ReadAll(location string) (string, error)

func (*MockTextRetriever) ReadLine added in v0.13.0

func (mtr *MockTextRetriever) ReadLine(location string, line int) (string, error)

func (*MockTextRetriever) WriteLineToFile added in v0.13.0

func (mtr *MockTextRetriever) WriteLineToFile(lineContent, location string, lineNumber int) error

func (*MockTextRetriever) WriteToFile added in v0.13.0

func (mtr *MockTextRetriever) WriteToFile(content string, location string) error

type Text added in v0.13.0

type Text struct{}

func (*Text) FileExists added in v0.13.0

func (t *Text) FileExists(location string) bool

func (*Text) ReadAll added in v0.13.0

func (t *Text) ReadAll(location string) (string, error)

ReadAll reads text content from a location (URL or filepath). The location accepts multiple input strings: starting with either "http://", "https://", or file url "file://" or filepath (default)

func (*Text) ReadLine added in v0.13.0

func (t *Text) ReadLine(location string, line int) (string, error)

ReadLine reads the specified line of text from the specified location (URL or filepath). The location accepts multiple input strings: starting with either "http://", "https://", or file url "file://" or filepath (default)

func (*Text) WriteLineToFile added in v0.13.0

func (t *Text) WriteLineToFile(lineContent, location string, lineNumber int) (err error)

WriteLineToFile writes 'lineContent' to the line number 'lineNumber' in the file at 'location'

func (*Text) WriteToFile added in v0.13.0

func (t *Text) WriteToFile(content string, location string) error

WriteToFile write a string to a file

type TextRetriever added in v0.13.0

type TextRetriever interface {
	ReadLine(location string, line int) (string, error)
	ReadAll(location string) (string, error)
	WriteToFile(content string, location string) error
	WriteLineToFile(lineContent, location string, lineNumber int) error
	FileExists(location string) bool
}

Jump to

Keyboard shortcuts

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