timers
This commit is contained in:
parent
1b4e6913aa
commit
691fa2dfe1
@ -1,3 +1,5 @@
|
|||||||
|
// ## Timers
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "time"
|
import "time"
|
4
092-timers/tiners.sh
Normal file
4
092-timers/tiners.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
$ go run timers.go
|
||||||
|
Timer 1 expired
|
||||||
|
Timer 2 stopped: false
|
||||||
|
Timer 2 stopped: true
|
@ -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])
|
|
||||||
}
|
|
29
093-urls/urls.go
Normal file
29
093-urls/urls.go
Normal file
@ -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])
|
||||||
|
}
|
13
093-urls/urls.sh
Normal file
13
093-urls/urls.sh
Normal file
@ -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
|
@ -90,7 +90,7 @@ tcp-server
|
|||||||
tickers
|
tickers
|
||||||
time
|
time
|
||||||
timers
|
timers
|
||||||
url
|
urls
|
||||||
users
|
users
|
||||||
worker-pool
|
worker-pool
|
||||||
line-filter
|
line-filter
|
Loading…
x
Reference in New Issue
Block a user