utils

package
v0.0.0-...-17fbf12 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package utils provides helper functions for other subpackages

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPathNotSet states that given path to file loader is empty
	ErrPathNotSet = errors.New("path is not set")

	// ErrFileNotFound states that given file is not exists
	ErrFileNotFound = errors.New("file not found")
)
View Source
var NewLinesRegex = regexp.MustCompile(`(?m:\s*$)`)

NewLinesRegex holds the regex to remove newlines from given bytes.Buffer

Functions

func Clear

func Clear(buf bytes.Buffer) ([]byte, error)

Clear formats the given source with predefined operations, it removes the new lines too

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads the given file, first it tries to read with relative path, then tries with exact given path

func RemoveNewLines

func RemoveNewLines(b []byte) []byte

RemoveNewLines removes extranneous new lines from given byte slice

func Write

func Write(fileName string, models []byte) error

Write writes a given model data into given fileName, if folders in the filename does not exist, creates the folders too.

func WriteFormattedFile

func WriteFormattedFile(fileName string, model []byte) error

WriteFormattedFile formats the code with goimports and writes the result to the given file, if file doesnt exists, it creates it

Types

This section is empty.

Jump to

Keyboard shortcuts

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