Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed May 21, 2022
1 parent 5697f7c commit 625f487
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package flagx_test

import (
"fmt"
"os"
"testing"
"time"

"github.com/cristalhq/flagx"
)

func ExampleFlagSet(t *testing.T) {
func ExampleFlagSet() {
var d time.Duration
fset := flagx.NewFlagSet("testing", os.Stderr)
fset.Duration(&d, "timeout", "t", 10*time.Second, "just a timeout")

err := fset.Parse([]string{"-t", "20s"})
if err != nil {
t.Fatal(err)
panic(err)
}

if d != 20*time.Second {
t.Fatalf("got %v want %v", d, 20*time.Second)
panic(fmt.Sprintf("got %v want %v", d, 20*time.Second))
}
}

0 comments on commit 625f487

Please sign in to comment.