Skip to content

Commit

Permalink
revert: revert some change
Browse files Browse the repository at this point in the history
some change are doing by PR pkg#206 and pkg#212 , so I don't need to do it

Signed-off-by: Sherlock Holo <[email protected]>
  • Loading branch information
Sherlock-Holo committed Nov 7, 2019
1 parent 057b7e2 commit d9389f6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 35 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ _testmain.go
*.exe
*.test
*.prof

.idea
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go:
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
- tip

script:
Expand Down
21 changes: 9 additions & 12 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ func (f *fundamental) Format(s fmt.State, verb rune) {
switch verb {
case 'v':
if s.Flag('+') {
_, _ = io.WriteString(s, f.msg)
io.WriteString(s, f.msg)
f.stack.Format(s, verb)
return
}
fallthrough
case 's':
_, _ = io.WriteString(s, f.msg)
io.WriteString(s, f.msg)
case 'q':
_, _ = fmt.Fprintf(s, "%q", f.msg)
fmt.Fprintf(s, "%q", f.msg)
}
}

Expand All @@ -159,21 +159,19 @@ type withStack struct {

func (w *withStack) Cause() error { return w.error }

func (w *withStack) Unwrap() error { return w.error }

func (w *withStack) Format(s fmt.State, verb rune) {
switch verb {
case 'v':
if s.Flag('+') {
_, _ = fmt.Fprintf(s, "%+v", w.Cause())
fmt.Fprintf(s, "%+v", w.Cause())
w.stack.Format(s, verb)
return
}
fallthrough
case 's':
_, _ = io.WriteString(s, w.Error())
io.WriteString(s, w.Error())
case 'q':
_, _ = fmt.Fprintf(s, "%q", w.Error())
fmt.Fprintf(s, "%q", w.Error())
}
}

Expand Down Expand Up @@ -242,19 +240,18 @@ type withMessage struct {

func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() }
func (w *withMessage) Cause() error { return w.cause }
func (w *withMessage) Unwrap() error { return w.cause }

func (w *withMessage) Format(s fmt.State, verb rune) {
switch verb {
case 'v':
if s.Flag('+') {
_, _ = fmt.Fprintf(s, "%+v\n", w.Cause())
_, _ = io.WriteString(s, w.msg)
fmt.Fprintf(s, "%+v\n", w.Cause())
io.WriteString(s, w.msg)
return
}
fallthrough
case 's', 'q':
_, _ = io.WriteString(s, w.Error())
io.WriteString(s, w.Error())
}
}

Expand Down
5 changes: 0 additions & 5 deletions go.mod

This file was deleted.

2 changes: 0 additions & 2 deletions go.sum

This file was deleted.

26 changes: 13 additions & 13 deletions stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ func (f Frame) Format(s fmt.State, verb rune) {
case 's':
switch {
case s.Flag('+'):
_, _ = io.WriteString(s, f.name())
_, _ = io.WriteString(s, "\n\t")
_, _ = io.WriteString(s, f.file())
io.WriteString(s, f.name())
io.WriteString(s, "\n\t")
io.WriteString(s, f.file())
default:
_, _ = io.WriteString(s, path.Base(f.file()))
io.WriteString(s, path.Base(f.file()))
}
case 'd':
_, _ = io.WriteString(s, strconv.Itoa(f.line()))
io.WriteString(s, strconv.Itoa(f.line()))
case 'n':
_, _ = io.WriteString(s, funcname(f.name()))
io.WriteString(s, funcname(f.name()))
case 'v':
f.Format(s, 's')
_, _ = io.WriteString(s, ":")
io.WriteString(s, ":")
f.Format(s, 'd')
}
}
Expand Down Expand Up @@ -110,11 +110,11 @@ func (st StackTrace) Format(s fmt.State, verb rune) {
switch {
case s.Flag('+'):
for _, f := range st {
_, _ = io.WriteString(s, "\n")
io.WriteString(s, "\n")
f.Format(s, verb)
}
case s.Flag('#'):
_, _ = fmt.Fprintf(s, "%#v", []Frame(st))
fmt.Fprintf(s, "%#v", []Frame(st))
default:
st.formatSlice(s, verb)
}
Expand All @@ -126,14 +126,14 @@ func (st StackTrace) Format(s fmt.State, verb rune) {
// formatSlice will format this StackTrace into the given buffer as a slice of
// Frame, only valid when called with '%s' or '%v'.
func (st StackTrace) formatSlice(s fmt.State, verb rune) {
_, _ = io.WriteString(s, "[")
io.WriteString(s, "[")
for i, f := range st {
if i > 0 {
_, _ = io.WriteString(s, " ")
io.WriteString(s, " ")
}
f.Format(s, verb)
}
_, _ = io.WriteString(s, "]")
io.WriteString(s, "]")
}

// stack represents a stack of program counters.
Expand All @@ -146,7 +146,7 @@ func (s *stack) Format(st fmt.State, verb rune) {
case st.Flag('+'):
for _, pc := range *s {
f := Frame(pc)
_, _ = fmt.Fprintf(st, "\n%+v", f)
fmt.Fprintf(st, "\n%+v", f)
}
}
}
Expand Down

0 comments on commit d9389f6

Please sign in to comment.