diff --git a/092-timers/092-timers.go b/092-timers/timers.go similarity index 96% rename from 092-timers/092-timers.go rename to 092-timers/timers.go index fb271af..536a5a3 100644 --- a/092-timers/092-timers.go +++ b/092-timers/timers.go @@ -1,3 +1,5 @@ +// ## Timers + package main import "time" diff --git a/092-timers/tiners.sh b/092-timers/tiners.sh new file mode 100644 index 0000000..d43f75f --- /dev/null +++ b/092-timers/tiners.sh @@ -0,0 +1,4 @@ +$ go run timers.go +Timer 1 expired +Timer 2 stopped: false +Timer 2 stopped: true diff --git a/093-url/093-url.go b/093-url/093-url.go deleted file mode 100644 index 05798ed..0000000 --- a/093-url/093-url.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ("fmt"; "net/url"; "strings") - -func main() { - u, err := url.Parse("postgres://user:pass@host.com:5432/path?k=v#frag") - if err != nil { panic(err) } - fmt.Println(u.Scheme) - fmt.Println(u.User) - fmt.Println(u.User.Username()) - p, _ := u.User.Password() - fmt.Println(p) - fmt.Println(u.Host) - split := strings.Split(u.Host, ":") - fmt.Println(split[0]) - fmt.Println(split[1]) - fmt.Println(u.Path) - fmt.Println(u.Fragment) - fmt.Println(u.RawQuery) - m, _ := url.ParseQuery(u.RawQuery) - fmt.Println(m) - fmt.Println(m["k"][0]) -} diff --git a/093-urls/urls.go b/093-urls/urls.go new file mode 100644 index 0000000..813b541 --- /dev/null +++ b/093-urls/urls.go @@ -0,0 +1,29 @@ +// ## URLs + +package main + +import "fmt" +import "net/url" +import "strings" + +func main() { + u, err := url.Parse("postgres://user:pass@host.com:5432/path?k=v#frag") + if err != nil { + panic(err) + } + fmt.Println(u.Scheme) + fmt.Println(u.User) + fmt.Println(u.User.Username()) + p, _ := u.User.Password() + fmt.Println(p) + fmt.Println(u.Host) + split := strings.Split(u.Host, ":") + fmt.Println(split[0]) + fmt.Println(split[1]) + fmt.Println(u.Path) + fmt.Println(u.Fragment) + fmt.Println(u.RawQuery) + m, _ := url.ParseQuery(u.RawQuery) + fmt.Println(m) + fmt.Println(m["k"][0]) +} diff --git a/093-urls/urls.sh b/093-urls/urls.sh new file mode 100644 index 0000000..6656766 --- /dev/null +++ b/093-urls/urls.sh @@ -0,0 +1,13 @@ +$ go run urls.go +postgres +user:pass +user +pass +host.com:5432 +host.com +5432 +/path +frag +k=v +map[k:[v]] +v diff --git a/tool/index.txt b/tool/index.txt index 4e055aa..98fa13d 100644 --- a/tool/index.txt +++ b/tool/index.txt @@ -90,7 +90,7 @@ tcp-server tickers time timers -url +urls users worker-pool line-filter \ No newline at end of file