cfmt

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: MIT Imports: 4 Imported by: 22

README



Cfmt

Contextual fmt




It provides contextual formatting functions that have nearly identical usage of the fmt package. The ideas were borrowed from bootstrap's contextual color classes.

Installation

go get github.com/mingrammer/cfmt

Usage

package main

import (
	"log"

	"github.com/mingrammer/cfmt"
)

func main() {
	cfmt.Success("User was created successfully")
	cfmt.Infoln("Here are some candidates")
	cfmt.Warningf("%s is not valid integer value\n", "123a")
	log.Fatal(cfmt.Serrorf("Only numeric is allowed, got %s", "123.456a"))
}

cfmt output

Contextual Functions

Note: cfmt.Errorf function does not do same things to fmt.Errorf, but to fmt.Printf with red colored text.

  • Success (Green)
    • Fsuccess, Fsuccessf, Fsuccessln
    • Success, Successf, Successln
    • Ssuccess, Ssuccessf, Ssuccessln
  • Info (Cyan)
    • Finfo, Finfof, Finfoln
    • Info, Infof, Infoln
    • Sinfo, Sinfof, Sinfoln
  • Warning (Yellow)
    • Fwarning, Fwarningf, Fwarningln
    • Warning, Warningf, Warningln
    • Swarning, Swarningf, Swarningln
  • Error (Red)
    • Ferror, Ferrorf, Ferrorln
    • Error, Errorf, Errorln
    • Serror, Serrorf, Serrorln

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(a ...interface{}) (n int, err error)

Error prints red colored text in manner of fmt.Print

func Errorf

func Errorf(format string, a ...interface{}) (n int, err error)

Errorf prints red colored text in manner of fmt.Printf

func Errorln

func Errorln(a ...interface{}) (n int, err error)

Errorln prints red colored text in manner of fmt.Println

func Ferror

func Ferror(w io.Writer, a ...interface{}) (n int, err error)

Ferror prints red colored text in manner of fmt.Fprint

func Ferrorf

func Ferrorf(w io.Writer, format string, a ...interface{}) (n int, err error)

Ferrorf writes red colored text in manner of fmt.Fprintf

func Ferrorln

func Ferrorln(w io.Writer, a ...interface{}) (n int, err error)

Ferrorln prints red colored text in manner of fmt.Fprintln

func Finfo

func Finfo(w io.Writer, a ...interface{}) (n int, err error)

Finfo prints cyan colored text in manner of fmt.Fprint

func Finfof

func Finfof(w io.Writer, format string, a ...interface{}) (n int, err error)

Finfof writes cyan colored text in manner of fmt.Fprintf

func Finfoln

func Finfoln(w io.Writer, a ...interface{}) (n int, err error)

Finfoln prints cyan colored text in manner of fmt.Fprintln

func Fsuccess

func Fsuccess(w io.Writer, a ...interface{}) (n int, err error)

Fsuccess prints green colored text in manner of fmt.Fprint

func Fsuccessf

func Fsuccessf(w io.Writer, format string, a ...interface{}) (n int, err error)

Fsuccessf writes green colored text in manner of fmt.Fprintf

func Fsuccessln

func Fsuccessln(w io.Writer, a ...interface{}) (n int, err error)

Fsuccessln prints green colored text in manner of fmt.Fprintln

func Fwarning

func Fwarning(w io.Writer, a ...interface{}) (n int, err error)

Fwarning prints yellow colored text in manner of fmt.Fprint

func Fwarningf

func Fwarningf(w io.Writer, format string, a ...interface{}) (n int, err error)

Fwarningf writes yellow colored text in manner of fmt.Fprintf

func Fwarningln

func Fwarningln(w io.Writer, a ...interface{}) (n int, err error)

Fwarningln prints yellow colored text in manner of fmt.Fprintln

func Info

func Info(a ...interface{}) (n int, err error)

Info prints cyan colored text in manner of fmt.Print

func Infof

func Infof(format string, a ...interface{}) (n int, err error)

Infof prints cyan colored text in manner of fmt.Printf

func Infoln

func Infoln(a ...interface{}) (n int, err error)

Infoln prints cyan colored text in manner of fmt.Println

func Serror

func Serror(a ...interface{}) string

Serror returns red colored string in manner of fmt.Sprint

func Serrorf

func Serrorf(format string, a ...interface{}) string

Serrorf returns red colored string in manner of fmt.Sprintf

func Serrorln

func Serrorln(a ...interface{}) string

Serrorln returns red colored string in manner of fmt.Sprintln

func Sinfo

func Sinfo(a ...interface{}) string

Sinfo returns cyan colored string in manner of fmt.Sprint

func Sinfof

func Sinfof(format string, a ...interface{}) string

Sinfof returns cyan colored string in manner of fmt.Sprintf

func Sinfoln

func Sinfoln(a ...interface{}) string

Sinfoln returns cyan colored string in manner of fmt.Sprintln

func Ssuccess

func Ssuccess(a ...interface{}) string

Ssuccess returns green colored string in manner of fmt.Sprint

func Ssuccessf

func Ssuccessf(format string, a ...interface{}) string

Ssuccessf returns green colored string in manner of fmt.Sprintf

func Ssuccessln

func Ssuccessln(a ...interface{}) string

Ssuccessln returns green colored string in manner of fmt.Sprintln

func Success

func Success(a ...interface{}) (n int, err error)

Success prints green colored text in manner of fmt.Print

func Successf

func Successf(format string, a ...interface{}) (n int, err error)

Successf prints green colored text in manner of fmt.Printf

func Successln

func Successln(a ...interface{}) (n int, err error)

Successln prints green colored text in manner of fmt.Println

func Swarning

func Swarning(a ...interface{}) string

Swarning returns yellow colored string in manner of fmt.Sprint

func Swarningf

func Swarningf(format string, a ...interface{}) string

Swarningf returns yellow colored string in manner of fmt.Sprintf

func Swarningln

func Swarningln(a ...interface{}) string

Swarningln returns yellow colored string in manner of fmt.Sprintln

func Warning

func Warning(a ...interface{}) (n int, err error)

Warning prints yellow colored text in manner of fmt.Print

func Warningf

func Warningf(format string, a ...interface{}) (n int, err error)

Warningf prints yellow colored text in manner of fmt.Printf

func Warningln

func Warningln(a ...interface{}) (n int, err error)

Warningln prints yellow colored text in manner of fmt.Println

Types

This section is empty.

Jump to

Keyboard shortcuts

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