Permalink
Browse files

Syntax highlighting in README.markdown

  • Loading branch information...
bbigras authored and dustin committed Nov 25, 2015
1 parent 64dbdae commit 8929fe90cee4b2cb9deb468b51fb34eba64d1bf0
Showing with 21 additions and 10 deletions.
  1. +21 −10 README.markdown
@@ -15,7 +15,9 @@ strings like, `83MB` or `79MiB` (whichever you prefer).

Example:

fmt.Printf("That file is %s.", humanize.Bytes(82854982))
```go
fmt.Printf("That file is %s.", humanize.Bytes(82854982))
```

## Times

@@ -24,7 +26,9 @@ For example, `12 seconds ago` or `3 days from now`.

Example:

fmt.Printf("This was touched %s", humanize.Time(someTimeInstance))
```go
fmt.Printf("This was touched %s", humanize.Time(someTimeInstance))
```

Thanks to Kyle Lemons for the time implementation from an IRC
conversation one day. It's pretty neat.
@@ -43,7 +47,9 @@ to label ordinals.

Example:

fmt.Printf("You're my %s best friend.", humanize.Ordinal(193))
```go
fmt.Printf("You're my %s best friend.", humanize.Ordinal(193))
```

## Commas

@@ -57,25 +63,30 @@ Want to shove commas into numbers? Be my guest.

Example:

fmt.Printf("You owe $%s.\n", humanize.Comma(6582491))
```go
fmt.Printf("You owe $%s.\n", humanize.Comma(6582491))
```

## Ftoa

Nicer float64 formatter that removes trailing zeros.

fmt.Printf("%f", 2.24) // 2.240000
fmt.Printf("%s", humanize.Ftoa(2.24)) // 2.24
fmt.Printf("%f", 2.0) // 2.000000
fmt.Printf("%s", humanize.Ftoa(2.0)) // 2
```go
fmt.Printf("%f", 2.24) // 2.240000
fmt.Printf("%s", humanize.Ftoa(2.24)) // 2.24
fmt.Printf("%f", 2.0) // 2.000000
fmt.Printf("%s", humanize.Ftoa(2.0)) // 2
```

## SI notation

Format numbers with [SI notation][sinotation].

Example:

humanize.SI(0.00000000223, "M") // 2.23nM

```go
humanize.SI(0.00000000223, "M") // 2.23nM
```

[odisc]: https://groups.google.com/d/topic/golang-nuts/l8NhI74jl-4/discussion
[sinotation]: http://en.wikipedia.org/wiki/Metric_prefix

0 comments on commit 8929fe9

Please sign in to comment.