Errata

Cloud Native Go

Errata for Cloud Native Go

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Chapter 4
Sample Code of DebounceLast

Passed "circuit" will never be called. Because ticker will be stopped just after closure completed.(closure may not takes 100 milliseconds). And stopped ticker can't be nil according to code so ticker never run again.

```golang
ticker = time.NewTicker(time.Millisecond * 100)
defer ticker.Stop() // change location to inside of goroutine
tickerc := ticker.C

```

Myungho Kim  Sep 27, 2020  Apr 20, 2021
online
4rd cloud native patterns -> concurrency patterns -> Shard

error code:

```go
func (m ShardedMap) getShardIndex(key string) int {
checksum := sha1.Sum([]byte(key)) // Use Sum from "crypto/sha1"
hash := int(checksum[17]) // Pick a random byte as our hash
index := hash % len(shards) // Mod by len(shards) to get index
}
```

have no return value and undefined variable `shards`, should be:

```go
func (m ShardedMap) getShardIndex(key string) int {
checksum := sha1.Sum([]byte(key)) // Use Sum from "crypto/sha1"
hash := int(checksum[17]) // Pick a random byte as our hash

return hash % len(m) // Mod by len(shards) to get index
}

Gaiheilu  Jan 03, 2021  Apr 20, 2021