Git Product home page Git Product logo

goutils's Introduction

GoUtils

Stability: Maintenance GoDoc Build Status Build status

GoUtils provides users with utility functions to manipulate strings in various ways. It is a Go implementation of some string manipulation libraries of Java Apache Commons. GoUtils includes the following Java Apache Commons classes:

  • WordUtils
  • RandomStringUtils
  • StringUtils (partial implementation)

Installation

If you have Go set up on your system, from the GOPATH directory within the command line/terminal, enter this:

go get github.com/Masterminds/goutils

If you do not have Go set up on your system, please follow the Go installation directions from the documenation, and then follow the instructions above to install GoUtils.

Documentation

GoUtils doc is available here: GoDoc

Usage

The code snippets below show examples of how to use GoUtils. Some functions return errors while others do not. The first instance below, which does not return an error, is the Initials function (located within the wordutils.go file).

package main

import (
    "fmt"
	"github.com/Masterminds/goutils"
)

func main() {

	// EXAMPLE 1: A goutils function which returns no errors
    fmt.Println (goutils.Initials("John Doe Foo")) // Prints out "JDF"

}

Some functions return errors mainly due to illegal arguements used as parameters. The code example below illustrates how to deal with function that returns an error. In this instance, the function is the Random function (located within the randomstringutils.go file).

package main

import (
    "fmt"
    "github.com/Masterminds/goutils"
)

func main() {

    // EXAMPLE 2: A goutils function which returns an error
    rand1, err1 := goutils.Random (-1, 0, 0, true, true)  

    if err1 != nil {
		fmt.Println(err1) // Prints out error message because -1 was entered as the first parameter in goutils.Random(...)
	} else {
		fmt.Println(rand1)
	}

}

License

GoUtils is licensed under the Apache License, Version 2.0. Please check the LICENSE.txt file or visit http://www.apache.org/licenses/LICENSE-2.0 for a copy of the license.

Issue Reporting

Make suggestions or report issues using the Git issue tracker: https://github.com/Masterminds/goutils/issues

Website

goutils's People

Contributors

aokoli avatar dbarranco avatar josephmilla avatar mattfarina avatar mattlorimor avatar technosophos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.