pool icon indicating copy to clipboard operation
pool copied to clipboard

A suggestion about Usage and documentation

Open fzxbl opened this issue 5 years ago • 0 comments

In the Batch Work example,The email.Value will be nil when called batch.Cancel() that will cause Panic as a result of wrong type desertation

for email := range batch.Results() {    
      if err := email.Error(); err != nil {
            // handle error
            // maybe call batch.Cancel()
        }

        // use return value 
       // The email.Value will be nil when called batch.Cancel() that will cause Panic as a result of wrong type desertation
        fmt.Println(email.Value().(bool)) 
    }

It might be good to write like this

for email := range batch.Results() {

        if err := email.Error(); err != nil {
            // handle error
            // maybe call batch.Cancel()
        }else{
       // use return value 
        fmt.Println(email.Value().(bool)) 
      }

fzxbl avatar May 15 '20 03:05 fzxbl