Skip to content

Commit

Permalink
example
Browse files Browse the repository at this point in the history
  • Loading branch information
sdfsdhgjkbmnmxc committed Nov 22, 2020
1 parent 057a28f commit c4786ea
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
}
```

0 comments on commit c4786ea

Please sign in to comment.