mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-22 12:46:03 +03:00
added a new iterator with error handling
Just finish the first pharse
This commit is contained in:
parent
d5aad34fce
commit
d1e5d3f1c1
27
concurrency/iterator_error_handling/main.go
Normal file
27
concurrency/iterator_error_handling/main.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FetchResult struct {
|
||||||
|
Domain string
|
||||||
|
StatusCode uint
|
||||||
|
Header string
|
||||||
|
}
|
||||||
|
|
||||||
|
func dummyFetchUrl(url string) *FetchResult {
|
||||||
|
time.Sleep(time.Second * 1)
|
||||||
|
return &FetchResult{
|
||||||
|
url,
|
||||||
|
200,
|
||||||
|
"Dummy Header",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
r := dummyFetchUrl("http://www.google.com")
|
||||||
|
spew.Dump(r)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user