Skip to content

Commit

Permalink
Fixing example output documentation
Browse files Browse the repository at this point in the history
I had originally put the `Output` in the examples in an awkward spot,
which meant that godoc (and https://pkg.go.dev/) was cutting off the
code before the end of the function.

This fixes that by putting the `Output` at the end of the function.
  • Loading branch information
Rican7 committed Aug 12, 2021
1 parent 466c8d7 commit 3673af5
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions backoff/backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ func ExampleIncremental() {
duration := algorithm(i)

fmt.Printf("#%d attempt: %s\n", i, duration)
// Output:
// #1 attempt: 25ms
// #2 attempt: 35ms
// #3 attempt: 45ms
// #4 attempt: 55ms
// #5 attempt: 65ms
}

// Output:
// #1 attempt: 25ms
// #2 attempt: 35ms
// #3 attempt: 45ms
// #4 attempt: 55ms
// #5 attempt: 65ms
}

func ExampleLinear() {
Expand All @@ -120,13 +121,14 @@ func ExampleLinear() {
duration := algorithm(i)

fmt.Printf("#%d attempt: %s\n", i, duration)
// Output:
// #1 attempt: 15ms
// #2 attempt: 30ms
// #3 attempt: 45ms
// #4 attempt: 60ms
// #5 attempt: 75ms
}

// Output:
// #1 attempt: 15ms
// #2 attempt: 30ms
// #3 attempt: 45ms
// #4 attempt: 60ms
// #5 attempt: 75ms
}

func ExampleExponential() {
Expand All @@ -136,13 +138,14 @@ func ExampleExponential() {
duration := algorithm(i)

fmt.Printf("#%d attempt: %s\n", i, duration)
// Output:
// #1 attempt: 45ms
// #2 attempt: 135ms
// #3 attempt: 405ms
// #4 attempt: 1.215s
// #5 attempt: 3.645s
}

// Output:
// #1 attempt: 45ms
// #2 attempt: 135ms
// #3 attempt: 405ms
// #4 attempt: 1.215s
// #5 attempt: 3.645s
}

func ExampleBinaryExponential() {
Expand All @@ -152,13 +155,14 @@ func ExampleBinaryExponential() {
duration := algorithm(i)

fmt.Printf("#%d attempt: %s\n", i, duration)
// Output:
// #1 attempt: 30ms
// #2 attempt: 60ms
// #3 attempt: 120ms
// #4 attempt: 240ms
// #5 attempt: 480ms
}

// Output:
// #1 attempt: 30ms
// #2 attempt: 60ms
// #3 attempt: 120ms
// #4 attempt: 240ms
// #5 attempt: 480ms
}

func ExampleFibonacci() {
Expand All @@ -168,11 +172,12 @@ func ExampleFibonacci() {
duration := algorithm(i)

fmt.Printf("#%d attempt: %s\n", i, duration)
// Output:
// #1 attempt: 15ms
// #2 attempt: 15ms
// #3 attempt: 30ms
// #4 attempt: 45ms
// #5 attempt: 75ms
}

// Output:
// #1 attempt: 15ms
// #2 attempt: 15ms
// #3 attempt: 30ms
// #4 attempt: 45ms
// #5 attempt: 75ms
}

0 comments on commit 3673af5

Please sign in to comment.