utilities

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2020 License: MIT Imports: 9 Imported by: 5

README

utilities

Go Quality Report GoDoc

utilities is a Go Library to share useful code, just that

Getting started

  • API documentation is available via godoc.

Installation

To install utilities package, you need to install Go and set your Go workspace first.

1 - The first need Go installed (version 1.13+ is required). Then you can use the below Go command to install Requist

$ go get -u github.com/dotWicho/utilities

And then Import it in your code:

package main

import "github.com/dotWicho/utilities"

Or

2 - Use as module in you project (go.mod file):

module myproject

go 1.13

require (
	github.com/dotWicho/utilities v1.0.2
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseName

func BaseName(str string) string

BaseName makes a string safe to use in a file name, producing a sanitized basename replacing . or / with -. No attempt is made to normalise a path or normalise case.

func CleanString

func CleanString(str string, r *regexp.Regexp) string

CleanString replaces separators with - and removes characters listed in the regexp provided from string. Accents, spaces, and all characters not in A-Za-z0-9 are replaced.

func DelInitialSlash

func DelInitialSlash(path string) string

DelInitialSlash just delete (if exists) a initial /

func EndsWithSlash

func EndsWithSlash(path string) string

EndsWithSlash just check if a path ends with /, if not add

func FileNameISO8601

func FileNameISO8601(fileName string) string

FileNameISO8601 returns a valid fileName with ISO8606 timestamp on it

func FilenameWithoutExtension added in v1.0.2

func FilenameWithoutExtension(fileName string) string

FilenameWithoutExtension returns a valid fileName without extension

func LoadDataFromJSON added in v1.0.1

func LoadDataFromJSON(body interface{}, fileName string) error

LoadDataFromJSON reads a JSON format file and returns its contents on body

func LoadDataFromYAML added in v1.0.1

func LoadDataFromYAML(body interface{}, fileName string) error

LoadDataFromYAML reads a YAML format file and returns its contents on body

func Name

func Name(str string) string

Name makes a string safe to use in a file name by first finding the path basename, then replacing non-ascii characters.

func ReadFile

func ReadFile(fileName string) []byte

ReadFile reads a file an returns its content if exists, on the other hand nil

func ValidFileName

func ValidFileName(folderName, fileName string) string

ValidFileName returns a valid fileName without not-ascii characters

func WriteDataToJSON added in v1.0.1

func WriteDataToJSON(body interface{}, fileName string) error

WriteDataToJSON saves the content of body in a JSON format file

func WriteDataToYAML added in v1.0.1

func WriteDataToYAML(body interface{}, fileName string) error

WriteDataToYAML saves the content of body in a YAML format file

Types

This section is empty.

Jump to

Keyboard shortcuts

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