Skip to content

Commit 0408b23

Browse files
author
probandula
committed
fixed goreportcard stuff
1 parent 48278c8 commit 0408b23

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

char.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type asciiChar struct {
1414
}
1515

1616
// Creates a new ascii character
17-
func NewAsciiChar(font *font, char rune) (*asciiChar, error) {
17+
func newAsciiChar(font *font, char rune) (*asciiChar, error) {
1818
// If not ascii, throw an error
1919
if char < 0 || char > 127 {
2020
return nil, errors.New("Not Ascii")

cmd/figlet4go/figlet4go.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package main
22

33
import (
4-
"errors"
54
"flag"
65
"fmt"
76
"github.com/fatih/color"
87
"github.com/probandula/figlet4go"
98
"log"
9+
"os"
1010
"strings"
1111
)
1212

@@ -22,10 +22,7 @@ func main() {
2222
flag.Parse()
2323

2424
// Validate and log the error
25-
err := validate()
26-
if err != nil {
27-
log.Fatal(err)
28-
}
25+
validate()
2926

3027
// Create objects
3128
ascii := figlet4go.NewAsciiRender()
@@ -87,9 +84,9 @@ func getColorSlice(colorStr string) []color.Attribute {
8784

8885
// Validate if all required options are given
8986
// flag.Parse() must be called before this
90-
func validate() error {
87+
func validate() {
9188
if *str == "" {
92-
return errors.New("No string given")
89+
flag.Usage()
90+
os.Exit(1)
9391
}
94-
return nil
9592
}

font.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package figlet4go
2+
23
// Explanation of the .flf file header
34
// THE HEADER LINE
45
//

fontmanager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (fm *fontManager) getFont(fontName string) *font {
6666
func (fm *fontManager) loadFontList(fontPath string) error {
6767
// Walk through the path
6868
return filepath.Walk(fontPath, func(path string, info os.FileInfo, err error) error {
69-
// Return an error if occured
69+
// Return an error if occurred
7070
if err != nil {
7171
return err
7272
}

render.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type RenderOptions struct {
1313
FontColor []color.Attribute
1414
}
1515

16-
// Create new RenderOptions
16+
// NewRenderOptions creates new RenderOptions
1717
// Sets the default font name
1818
func NewRenderOptions() *RenderOptions {
1919
return &RenderOptions{
@@ -27,25 +27,25 @@ type AsciiRender struct {
2727
fontMgr *fontManager
2828
}
2929

30-
// Create a new AsciiRender
30+
// NewAsciiRender creates a new AsciiRender
3131
func NewAsciiRender() *AsciiRender {
3232
return &AsciiRender{
3333
fontMgr: newFontManager(),
3434
}
3535
}
3636

37-
// Loading all *.flf font files recursively in a path
37+
// LoadFont loads all *.flf font files recursively in a path
3838
func (ar *AsciiRender) LoadFont(fontPath string) error {
3939
return ar.fontMgr.loadFontList(fontPath)
4040
}
4141

42-
// Render a string with the default options
42+
// Render renders a string with the default options
4343
// Calls the RenderOpts method with a new RenderOptions object
4444
func (ar *AsciiRender) Render(str string) (string, error) {
4545
return ar.RenderOpts(str, NewRenderOptions())
4646
}
4747

48-
// Render a string with special RenderOptions
48+
// RenderOpts renders a string with special RenderOptions
4949
// Can be called from the user (if options wished) or the above Render method
5050
// Contains the whole rendering logic
5151
func (ar *AsciiRender) RenderOpts(str string, opt *RenderOptions) (string, error) {
@@ -64,7 +64,7 @@ func (ar *AsciiRender) RenderOpts(str string, opt *RenderOptions) (string, error
6464
// Foreach char create the ascii char
6565
for _, char := range str {
6666
// AsciiChar
67-
asciiChar, err := NewAsciiChar(font, char)
67+
asciiChar, err := newAsciiChar(font, char)
6868
if err != nil {
6969
return "", err
7070
}

0 commit comments

Comments
 (0)