Skip to content

Commit

Permalink
chore: no snake case names in Go
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoVeille committed Jul 17, 2024
1 parent 02783e9 commit a79e937
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
11 changes: 6 additions & 5 deletions dumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Style interface {
Apply(string) string
}

//nolint:revive // this name is uncommon, but why not
func __(s Style, v string) string {
if s == nil {
return v
Expand Down Expand Up @@ -178,8 +179,8 @@ func (d *Dumper) init() {
}
}

func (d *Dumper) dump(val reflect.Value, ignore_depth ...bool) {
if len(ignore_depth) <= 0 || !ignore_depth[0] {
func (d *Dumper) dump(val reflect.Value, ignoreDepth ...bool) {
if len(ignoreDepth) <= 0 || !ignoreDepth[0] {
d.indent()
}

Expand Down Expand Up @@ -324,7 +325,7 @@ func (d *Dumper) dumpStruct(v reflect.Value) {
d.buf.WriteString(__(d.Theme.Braces, " {"))
d.buf.WriteString(__(d.Theme.PointerTag, tag))

var has_fields bool
var hasFields bool

d.depth++
for i := 0; i < v.NumField(); i++ {
Expand All @@ -333,7 +334,7 @@ func (d *Dumper) dumpStruct(v reflect.Value) {
continue
}

has_fields = true
hasFields = true

d.buf.WriteString("\n")
d.indent()
Expand All @@ -345,7 +346,7 @@ func (d *Dumper) dumpStruct(v reflect.Value) {
}
d.depth--

if has_fields {
if hasFields {
d.buf.WriteString("\n")
d.indent()
}
Expand Down
19 changes: 9 additions & 10 deletions dumper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,29 +813,28 @@ func TestDumperFprintReturnsAWriteErrorIfEncountered(t *testing.T) {
} else if err.Error() != "dumper error: encountered unexpected write error, foobar" {
t.Fatalf("unexpected error by Dumper.Fprintln : `%s`", err.Error())
}

}

func checkFromFeed(t *testing.T, result []byte, feed_path string) {
func checkFromFeed(t *testing.T, result []byte, feedPath string) {
t.Helper()

expectedOutput, err := os.ReadFile(feed_path)
expectedOutput, err := os.ReadFile(feedPath)
if err != nil {
t.Fatal(err)
}

r_lines := bytes.Split(result, []byte("\n"))
e_lines := bytes.Split(expectedOutput, []byte("\n"))
resultLines := bytes.Split(result, []byte("\n"))
expectedLines := bytes.Split(expectedOutput, []byte("\n"))

if len(r_lines) != len(e_lines) {
t.Fatalf("expected %d lines, got %d", len(e_lines), len(r_lines))
if len(resultLines) != len(expectedLines) {
t.Fatalf("expected %d lines, got %d", len(expectedLines), len(resultLines))
}

for i, line := range e_lines {
if string(line) != string(r_lines[i]) {
for i, line := range expectedLines {
if string(line) != string(resultLines[i]) {
t.Fatalf(`mismatche at line %d:
--- "%s" (%d)
+++ "%s" (%d)`, i+1, line, len(line), r_lines[i], len(r_lines[i]))
+++ "%s" (%d)`, i+1, line, len(line), resultLines[i], len(resultLines[i]))
}
}
}

0 comments on commit a79e937

Please sign in to comment.