utilities

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 License: MIT Imports: 11 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.0
)

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 LoadDataFromJson

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

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

func LoadDataFromYaml

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 conte

func ValidFileName

func ValidFileName(folderName, fileName string) string

ValidFileName returns a valid fileName without not-ascii characters

func WriteDataToJson

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

WriteDataToJson saves the content of body in a JSON format file

func WriteDataToYaml

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