Skip to content

Commit

Permalink
Lint fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengarrett committed Aug 8, 2020
1 parent 921458d commit e1bfbca
Show file tree
Hide file tree
Showing 10 changed files with 1,202 additions and 1,202 deletions.
38 changes: 19 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module retrotxt.com/retrotxt

go 1.13

require (
github.com/alecthomas/chroma v0.7.3
github.com/aofei/mimesniffer v1.1.4
github.com/gookit/color v1.2.6
github.com/mozillazg/go-slugify v0.2.0
github.com/mozillazg/go-unidecode v0.1.1 // indirect
github.com/muesli/go-app-paths v0.2.1
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.7.0
github.com/tdewolff/minify v2.3.6+incompatible
github.com/tdewolff/parse v2.3.4+incompatible // indirect
github.com/tdewolff/test v1.0.6 // indirect
golang.org/x/text v0.3.3
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
)
module retrotxt.com/retrotxt

go 1.13

require (
github.com/alecthomas/chroma v0.7.3
github.com/aofei/mimesniffer v1.1.4
github.com/gookit/color v1.2.6
github.com/mozillazg/go-slugify v0.2.0
github.com/mozillazg/go-unidecode v0.1.1 // indirect
github.com/muesli/go-app-paths v0.2.1
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.7.0
github.com/tdewolff/minify v2.3.6+incompatible
github.com/tdewolff/parse v2.3.4+incompatible // indirect
github.com/tdewolff/test v1.0.6 // indirect
golang.org/x/text v0.3.3
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
)
734 changes: 367 additions & 367 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.22
0.0.23
114 changes: 57 additions & 57 deletions lib/convert/simple.go
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
package convert

import (
"errors"
"fmt"
"io/ioutil"
"strings"
"unicode/utf8"

"golang.org/x/text/encoding/charmap"
"golang.org/x/text/transform"
)

var ErrNoUTF8 = errors.New("string is not encoded as utf8")

// DString decodes simple character encoding text.
func DString(s string, c *charmap.Charmap) (result []byte, err error) {
decoder := c.NewDecoder()
reader := transform.NewReader(strings.NewReader(s), decoder)
result, err = ioutil.ReadAll(reader)
if err != nil {
return nil, fmt.Errorf("dstring ioutil readall error: %w", err)
}
return result, nil
}

// EString encodes text into a simple character encoding.
func EString(s string, c *charmap.Charmap) (result []byte, err error) {
if !utf8.Valid([]byte(s)) {
return result, fmt.Errorf("estring: %w", ErrNoUTF8)
}
encoder := c.NewEncoder()
reader := transform.NewReader(strings.NewReader(s), encoder)
result, err = ioutil.ReadAll(reader)
if err != nil {
return nil, fmt.Errorf("estring ioutil readall error: %w", err)
}
return result, nil
}

// D437 decodes IBM Code Page 437 encoded text.
func D437(s string) (result []byte, err error) {
result, err = DString(s, charmap.CodePage437)
if err != nil {
return nil, fmt.Errorf("decode code page 437: %w", err)
}
return result, nil
}

// E437 encodes text into IBM Code Page 437.
func E437(s string) (result []byte, err error) {
result, err = EString(s, charmap.CodePage437)
if err != nil {
return nil, fmt.Errorf("encode code page 437: %w", err)
}
return result, nil
}
package convert

import (
"errors"
"fmt"
"io/ioutil"
"strings"
"unicode/utf8"

"golang.org/x/text/encoding/charmap"
"golang.org/x/text/transform"
)

var ErrNoUTF8 = errors.New("string is not encoded as utf8")

// DString decodes simple character encoding text.
func DString(s string, c *charmap.Charmap) (result []byte, err error) {
decoder := c.NewDecoder()
reader := transform.NewReader(strings.NewReader(s), decoder)
result, err = ioutil.ReadAll(reader)
if err != nil {
return nil, fmt.Errorf("dstring ioutil readall error: %w", err)
}
return result, nil
}

// EString encodes text into a simple character encoding.
func EString(s string, c *charmap.Charmap) (result []byte, err error) {
if !utf8.Valid([]byte(s)) {
return result, fmt.Errorf("estring: %w", ErrNoUTF8)
}
encoder := c.NewEncoder()
reader := transform.NewReader(strings.NewReader(s), encoder)
result, err = ioutil.ReadAll(reader)
if err != nil {
return nil, fmt.Errorf("estring ioutil readall error: %w", err)
}
return result, nil
}

// D437 decodes IBM Code Page 437 encoded text.
func D437(s string) (result []byte, err error) {
result, err = DString(s, charmap.CodePage437)
if err != nil {
return nil, fmt.Errorf("decode code page 437: %w", err)
}
return result, nil
}

// E437 encodes text into IBM Code Page 437.
func E437(s string) (result []byte, err error) {
result, err = EString(s, charmap.CodePage437)
if err != nil {
return nil, fmt.Errorf("encode code page 437: %w", err)
}
return result, nil
}
Loading

0 comments on commit e1bfbca

Please sign in to comment.