utils

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package utils are utilities helpers for gexpo.

Index

Constants

View Source
const FgGreen = "\033[32m"

FgGreen is green foreground color.

View Source
const FgRed = "\033[31m"

FgRed is red foreground color.

View Source
const FgYellow = "\033[33m"

FgYellow is yellow foreground color.

Variables

This section is empty.

Functions

func CheckPath

func CheckPath(path string) bool

CheckPath will check if folder/file exist.

func CommandExist

func CommandExist(command string) bool

CommandExist will check if command exist or not.

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf format text and call os.Exit 1.

func GetJson

func GetJson(url string, result interface{}) error

GetJson will fetch to api and decode json result into struct.

func GetRaw

func GetRaw(url string) ([]byte, error)

GetRaw will fetch to api and decode it to raw byte.

func NewSpinner

func NewSpinner() *yacspin.Spinner

NewSpinner will create new spinner.

func ReadFile

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

ReadFile will read a file. Params target is the full path of the file. The result will be returned as []byte

func ReadJson

func ReadJson(target string, result interface{}) error

ReadJson will read json file. Params target is the full path of the file. Params result is interface of the file.

func ReadJsonUseNumber added in v0.1.2

func ReadJsonUseNumber(target string, result interface{}) error

ReadJsonUseNumber will read json file and use json.Number instead float64 for number inside json. Params target is the full path of the file. Params result is interface of the file.

func WriteFile

func WriteFile(target string, data []byte) error

WriteFile will write new file. Params target is the full path of the file.

func WriteJson

func WriteJson(target string, data interface{}) error

WriteJson will write json formated file. Params target is the full path of the file.

Types

type Cl

type Cl struct {
	Current string // The current used colors.
}

Cl are simple color library for the app.

func Colors

func Colors(color string) *Cl

Colors will set current colors.

func (*Cl) Sprint

func (c *Cl) Sprint(v string) string

Sprint will return string formated with colors.

func (*Cl) SprintFunc

func (c *Cl) SprintFunc() func(v string) string

SprintFunc will return Sprint function with colorized text.

Jump to

Keyboard shortcuts

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