-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathprintf.go
More file actions
22 lines (19 loc) · 554 Bytes
/
Copy pathprintf.go
File metadata and controls
22 lines (19 loc) · 554 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package tml
import (
"fmt"
"io"
"os"
)
// Printf works like fmt.Printf, but adds the option of using tags to apply colour or text formatting to the written text. For example "<red>some red text</red>".
// A full list of tags is available here: https://github.com/liamg/tml
func Printf(input string, a ...interface{}) error {
return Fprintf(os.Stdout, input, a...)
}
func Fprintf(w io.Writer, input string, a ...interface{}) error {
format, err := Parse(input)
if err != nil {
return err
}
_, err = fmt.Fprintf(w, format, a...)
return err
}