Save all the things
parent
2a537f5b54
commit
6a1469fc73
@ -0,0 +1,6 @@
|
|||||||
|
# Learning SQL DB Access
|
||||||
|
|
||||||
|
|
||||||
|
Resources:
|
||||||
|
|
||||||
|
http://go-database-sql.org/index.html It's the missing guide to the docs "how" to use the database/sql package.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,13 @@
|
|||||||
|
package concurrency
|
||||||
|
|
||||||
|
type WebsiteChecker func(string) bool
|
||||||
|
|
||||||
|
func CheckWebsites(wc WebsiteChecker, urls []string) map[string]bool {
|
||||||
|
results := make(map[string]bool)
|
||||||
|
|
||||||
|
for _, url := range urls {
|
||||||
|
results[url] = wc(url)
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package concurrency
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func mockWebsiteChecker(url string) bool {
|
||||||
|
return url != "waat://furhurterwe.geds"
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWebsites(t *testing.T) {
|
||||||
|
websites := []string{
|
||||||
|
"http://google.com",
|
||||||
|
"http://hackaday.com",
|
||||||
|
"waat://furhurterwe.geds",
|
||||||
|
}
|
||||||
|
|
||||||
|
want := map[string]bool{
|
||||||
|
"http://google.com": true,
|
||||||
|
"http://hackaday.com": true,
|
||||||
|
"waat://furhurterwe.geds": false,
|
||||||
|
}
|
||||||
|
|
||||||
|
got := CheckWebsites(mockWebsiteChecker, websites)
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(want, got) {
|
||||||
|
t.Fatalf("Wanted %v, got %v", want, got)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
module concurrency
|
||||||
|
|
||||||
|
go 1.22.5
|
Loading…
Reference in New Issue