Skip to content
🎨 Contextual fmt inspired by bootstrap color classes
Branch: master
Clone or download
Latest commit b8a7e4a Dec 7, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
images Initial commit Mar 15, 2018
.gitignore Initial commit Mar 15, 2018
.travis.yml Update .travis.yml Mar 15, 2018
Gopkg.lock Initial commit Mar 15, 2018
Gopkg.toml Initial commit Mar 15, 2018
LICENSE Create LICENSE Mar 15, 2018
README.md Update README.md Dec 7, 2018
cfmt.go Refactor Dec 5, 2018
cfmt_test.go Refactor Dec 5, 2018
codecov.yml
go.mod Support go modules Sep 2, 2018
go.sum Support go modules Sep 2, 2018

README.md



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

You can’t perform that action at this time.