Grokking Advanced Go
Vote

0% completed

​

Fuzzing

The function below reads one line of an order file, in the form SKU:quantity:price. Its table test has six rows, and all six pass. Before reading further, look at parseCents and try to name a line that makes this code panic, and a line that it accepts but reads as the wrong price.

// file: parse.go package orders import ( "fmt" "strconv" "strings" ) type Item struct { SKU string Quantity int Cents int64 } // ParseItem reads one line of an order file: SKU:quantity:price, // where the price is written in dollars and cents, such as 12.50.

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content