diff --git a/README.md b/README.md index b76eaa0..9a78349 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ # swap variables + +```go +// myconfig.go + +var myConfig struct { + Foo string + Bar int +} + +func init() { + readConfig(&myConfig) +} + +// test.go +import "github.com/tada-team/swap" + +func TestWithSwap(t *testing.T) { + defer swap.Bool(&myConfig.Foo, "test value")() + defer swap.Int(&myConfig.Bar, 42)() + + // test cases +} +```