utils

package
v0.0.0-...-2279c88 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCommentBlock

func GetCommentBlock(src []byte, index int) (block []string)

GetCommentBlock takes a byte array and a start position and may return a comment block if it finds one

func LineCounter

func LineCounter(r io.Reader) (int, error)

LineCounter counts lines in a string/byte buffer

func ParseType

func ParseType(t string, loc *ast.Location) ast.Type

ParseType Convert a schema type to a ast.Type

Types

type Lifo

type Lifo struct {
	Stack []interface{}
}

Lifo stack

func (*Lifo) Pop

func (lifo *Lifo) Pop() interface{}

Pop an element from the top of the stack

func (*Lifo) Push

func (lifo *Lifo) Push(elem interface{})

Push a new element on the top of the stack

type Line

type Line struct {
	Start  int
	End    int
	Source []byte
}

Line represents a line of text in context of a byte array

func GetLine

func GetLine(src []byte, index int) (Line, error)

GetLine takes a byte array and a start position returns a line

func (Line) IsStartOfLine

func (line Line) IsStartOfLine(index int) bool

IsStartOfLine returns true if index is inside the white space between the beginning of the line and any non white space character

func (Line) Text

func (line Line) Text() string

Text returns the contents of the line as a string

type OpaqueBytesBuffer

type OpaqueBytesBuffer interface {
	GetBuffer() *bytes.Buffer
}

OpaqueBytesBuffer is a genereic byte buffer interface

type SwapBuffer

type SwapBuffer struct {
	// contains filtered or unexported fields
}

SwapBuffer is a writeable buffer where the underlying buffer can be swaped

func (SwapBuffer) GetBuffer

func (tb SwapBuffer) GetBuffer() OpaqueBytesBuffer

GetBuffer gets get current buffer

func (*SwapBuffer) SetBuffer

func (tb *SwapBuffer) SetBuffer(b OpaqueBytesBuffer)

SetBuffer swaps the current buffer with b

func (SwapBuffer) Write

func (tb SwapBuffer) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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