Skip to content

Commit

Permalink
formate codes and fix some lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Dec 13, 2019
1 parent 4081f10 commit acc3216
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 20 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ func RestoreStdout() (s string)
func RewriteStdout()
```

## Code Check

```bash
gofmt -w -l ./
golint ./...
```

## License

[MIT](LICENSE)
2 changes: 0 additions & 2 deletions cliutil/cliutil_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
package cliutil


4 changes: 2 additions & 2 deletions dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ type dumpConfig struct {
// Config dump data settings
var Config = dumpConfig{
ShowMethod: true,
MoreLenNL: 8,
MoreLenNL: 8,
}

// ResetConfig reset config data
func ResetConfig() {
Config = dumpConfig{
ShowMethod: true,
MoreLenNL: 8,
MoreLenNL: 8,
}
}

Expand Down
2 changes: 1 addition & 1 deletion fmtutil/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ func TestStringsToInts(t *testing.T) {

_, err = fmtutil.StringsToInts([]string{"a", "b"})
is.Error(err)
}
}
2 changes: 1 addition & 1 deletion mathutil/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

var (
errConvertFail = errors.New("convert data type is failure")
errConvertFail = errors.New("convert data type is failure")
)

/*************************************************************
Expand Down
4 changes: 2 additions & 2 deletions strutil/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (
)

var (
// escape string.
// EscapeJS escape javascript string
EscapeJS = template.JSEscapeString
// EscapeHTML escape html string
EscapeHTML = template.HTMLEscapeString
)

Expand Down Expand Up @@ -59,4 +60,3 @@ func URLDecode(s string) string {

return s
}

10 changes: 5 additions & 5 deletions strutil/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import (
"github.com/stretchr/testify/assert"
)

func TestEscape(t *testing.T) {
tests := struct {give, want string} {
func TestEscape(t *testing.T) {
tests := struct{ give, want string }{
"<p>some text</p>",
"&lt;p&gt;some text&lt;/p&gt;",
}

assert.Equal(t, tests.want, strutil.EscapeHTML(tests.give))

tests = struct {give, want string} {
"<script>var a = 23;</script>",
`\x3Cscript\x3Evar a = 23;\x3C/script\x3E`,
tests = struct{ give, want string }{
"<script>var a = 23;</script>",
`\x3Cscript\x3Evar a = 23;\x3C/script\x3E`,
}
assert.Equal(t, tests.want, strutil.EscapeJS(tests.give))
}
Expand Down
1 change: 0 additions & 1 deletion strutil/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,3 @@ func CamelCase(s string, sep ...string) string {
return UpperFirst(s)
})
}

2 changes: 1 addition & 1 deletion strutil/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ func TestCamelCase(t *testing.T) {
// custom sep char
is.Equal("rangePrice", strutil.CamelCase("range+price", "+"))
is.Equal("rangePrice", strutil.CamelCase("range*price", "*"))
}
}
3 changes: 2 additions & 1 deletion strutil/strutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"text/template"
)

// Position for padding string
const (
PosLeft uint8 = iota
PosRight
Expand Down Expand Up @@ -123,7 +124,7 @@ func PadRight(s, pad string, length int) string {
// Repeat repeat a string
func Repeat(s string, times int) string {
if times < 2 {
return s
return s
}

var ss []string
Expand Down
8 changes: 4 additions & 4 deletions strutil/strutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ func TestRepeat(t *testing.T) {
}

func TestPadding(t *testing.T) {
tests := []struct{
tests := []struct {
want, give, pad string
len int
pos uint8
} {
len int
pos uint8
}{
{"ab000", "ab", "0", 5, strutil.PosRight},
{"000ab", "ab", "0", 5, strutil.PosLeft},
}
Expand Down

0 comments on commit acc3216

Please sign in to comment.