Save all the things

pull/1/head
Drew Bednar 5 months ago
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.

@ -266,4 +266,7 @@ func main() {
log.Fatal(err)
}
}
// Each driver has it's own error types
}

@ -19,3 +19,15 @@ I've taken this project a bit further then the article. Follow on work can inclu
- [ ] Runs test suite
- [ ] Tarball release artifact on Promote
- [ ] Deb release artifact on Promote
## Adding Libsql to a project
First install the driver
```
go get github.com/tursodatabase/go-libsql
```
We will only use a local file for this project. We will will use `GO_WIKI_DB` environment variable to determine where the SQLite file is located. It will default to ./data like the previous file based system.

@ -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…
Cancel
Save