Please use go fmt to format the code

This commit is contained in:
honggengwei
2014-10-23 14:56:35 +08:00
parent 1b8fc48341
commit 60fe917ec1

View File

@@ -1,49 +1,49 @@
package main package main
import ( import (
"fmt" "flag"
"github.com/fatih/color" "fmt"
"github.com/getwe/figlet4go" "github.com/fatih/color"
"flag" "github.com/getwe/figlet4go"
) )
var flag_str = flag.String("str", "golang", "input string") var flag_str = flag.String("str", "golang", "input string")
func main() { func main() {
flag.Parse() flag.Parse()
str := *flag_str str := *flag_str
ascii := figlet4go.NewAsciiRender() ascii := figlet4go.NewAsciiRender()
// most simple Usage // most simple Usage
renderStr, _ := ascii.Render(str) renderStr, _ := ascii.Render(str)
fmt.Println(renderStr) fmt.Println(renderStr)
// change the font color // change the font color
colors := [...]color.Attribute{ colors := [...]color.Attribute{
color.FgMagenta, color.FgMagenta,
color.FgYellow, color.FgYellow,
color.FgBlue, color.FgBlue,
color.FgCyan, color.FgCyan,
color.FgRed, color.FgRed,
color.FgWhite, color.FgWhite,
} }
options := figlet4go.NewRenderOptions() options := figlet4go.NewRenderOptions()
options.FontColor = make([]color.Attribute, len(str)) options.FontColor = make([]color.Attribute, len(str))
for i := range options.FontColor { for i := range options.FontColor {
options.FontColor[i] = colors[i % len(colors)] options.FontColor[i] = colors[i%len(colors)]
} }
renderStr, _ = ascii.RenderOpts(str, options) renderStr, _ = ascii.RenderOpts(str, options)
fmt.Println(renderStr) fmt.Println(renderStr)
// change the font // change the font
options.FontName = "larry3d" options.FontName = "larry3d"
// except the default font,others need to be load from disk // except the default font,others need to be load from disk
// here is the font : // here is the font :
// ftp://ftp.figlet.org/pub/figlet/fonts/contributed.tar.gz // ftp://ftp.figlet.org/pub/figlet/fonts/contributed.tar.gz
// ftp://ftp.figlet.org/pub/figlet/fonts/international.tar.gz // ftp://ftp.figlet.org/pub/figlet/fonts/international.tar.gz
// download and extract to the disk,then specify the file path to load // download and extract to the disk,then specify the file path to load
ascii.LoadFont("/usr/local/Cellar/figlet/2.2.5/share/figlet/fonts/") ascii.LoadFont("/usr/local/Cellar/figlet/2.2.5/share/figlet/fonts/")
renderStr, _ = ascii.RenderOpts(str, options) renderStr, _ = ascii.RenderOpts(str, options)
fmt.Println(renderStr) fmt.Println(renderStr)
} }