Skip to content

Commit

Permalink
Merge pull request #2 from FrozenDroid/patch-1
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
snksoft authored Feb 13, 2018
2 parents d390ecf + 47b698b commit 571a7cc
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ go get github.com/snksoft/crc

## Usage

Using src is easy. Here is an example of calculating CCITT crc.
Using `crc` is easy. Here is an example of calculating a CCITT crc.
```go
package main

Expand All @@ -33,7 +33,8 @@ func main() {
}
```

For larger data, table driven implementation is faster. Here is how to use it. Note that crc.Hash impements hash.Hash interface, so you can use it instead if you want.
For larger data, table driven implementation is faster. Note that `crc.Hash` implements `hash.Hash` interface, so you can use it instead if you want.
Here is how to use it:
```go
package main

Expand All @@ -58,13 +59,13 @@ func main() {
}
```
## Notes
Beware that Hash instance is not thread safe. If you want to do parallel CRC calculations, then either use NewHash() to create multiple Hash instances or simply make a copy of Hash whehever you need it. Latter option avoids recalculating CRC table, but keep in mind that NewHash() returns a pointer, so simple assignement will point to the same instance.
Use either
Beware that Hash instance is not thread safe. If you want to do parallel CRC calculations, then either use `NewHash()` to create multiple Hash instances or simply make a copy of Hash whehever you need it. Latter option avoids recalculating CRC table, but keep in mind that `NewHash()` returns a pointer, so simple assignement will point to the same instance.
Use either
```go
hash2 := &crc.Hash{}
*hash2 = *hash
hash2 := &crc.Hash{}
*hash2 = *hash
```
or simply
or simply
```go
var hash2 = *hash
var hash2 = *hash
```

0 comments on commit 571a7cc

Please sign in to comment.