updates
This commit is contained in:
parent
70dd607774
commit
6750b72724
@ -1,6 +1,9 @@
|
||||
// ## Select
|
||||
|
||||
package main
|
||||
|
||||
import ("fmt"; "time")
|
||||
import "time"
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
c1 := make(chan string)
|
@ -1,6 +1,9 @@
|
||||
// ## Timeouts
|
||||
|
||||
package main
|
||||
|
||||
import ("fmt"; "time")
|
||||
import "time"
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
c := make(chan string)
|
@ -1,6 +1,9 @@
|
||||
// ## String Functions
|
||||
|
||||
package main
|
||||
|
||||
import ("fmt"; "strings")
|
||||
import "strings"
|
||||
import "fm"
|
||||
|
||||
func p(o interface{}) {
|
||||
fmt.Println(o)
|
@ -1,3 +1,5 @@
|
||||
// ## Bytes
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
@ -1,25 +0,0 @@
|
||||
package main // Use `os.Args` to access command-line arguments and
|
||||
// the name of the program.
|
||||
import ("os"; "fmt")
|
||||
|
||||
func main() {
|
||||
argsWithProg := os.Args // `os.Args` includes the program name as the first
|
||||
argsWithoutProg := os.Args[1:] // value.
|
||||
|
||||
arg := os.Args[3] // `Args` are a slice, you can get individual args
|
||||
// with normal indexing.
|
||||
|
||||
fmt.Println(argsWithProg)
|
||||
fmt.Println(argsWithoutProg)
|
||||
fmt.Println(arg)
|
||||
}
|
||||
|
||||
/*
|
||||
$ go build command-line-args // Build a `command-line-args` binary so that we have
|
||||
// the expected program name.
|
||||
|
||||
$ ./command-line-args a b c d
|
||||
[command-line-args a b c d]
|
||||
[a b c d]
|
||||
c
|
||||
*/
|
26
044-command-line-arguments/command-line-arguments.go
Normal file
26
044-command-line-arguments/command-line-arguments.go
Normal file
@ -0,0 +1,26 @@
|
||||
// ## Command Line Arguments
|
||||
|
||||
// Use `os.Args` to access command-line arguments and
|
||||
// the name of the program.
|
||||
package main
|
||||
|
||||
import "os"
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// `os.Args` includes the program name as the first
|
||||
// value.
|
||||
argsWithProg := os.Args
|
||||
argsWithoutProg := os.Args[1:]
|
||||
|
||||
// `Args` are a slice, you can get individual args
|
||||
// with normal indexing.
|
||||
arg := os.Args[3]
|
||||
|
||||
|
||||
fmt.Println(argsWithProg)
|
||||
fmt.Println(argsWithoutProg)
|
||||
fmt.Println(arg)
|
||||
}
|
||||
|
||||
// todo: discuss building before here
|
9
044-command-line-arguments/command-line-arguments.sh
Normal file
9
044-command-line-arguments/command-line-arguments.sh
Normal file
@ -0,0 +1,9 @@
|
||||
# Build a `command-line-args` binary so that we have
|
||||
# the expected program name.
|
||||
$ go build command-line-arguments
|
||||
|
||||
|
||||
$ ./command-line-arguments a b c d
|
||||
[command-line-arguments a b c d]
|
||||
[a b c d]
|
||||
c
|
@ -1,3 +1,5 @@
|
||||
// ## Burstable Rate Limiting
|
||||
|
||||
package main
|
||||
|
||||
import "time"
|
@ -1,7 +0,0 @@
|
||||
package main
|
||||
|
||||
import ("net/dns", "fmt")
|
||||
|
||||
func main() {
|
||||
// https://github.com/miekg/dns/blob/master/ex/q/q.go
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
// ## Elapsed Time
|
||||
|
||||
package main
|
||||
|
||||
import ("time"; "fmt")
|
||||
import "time"
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
start := time.Now()
|
@ -1,8 +1,8 @@
|
||||
// ## Email
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/smtp"
|
||||
)
|
||||
import "net/smtp"
|
||||
|
||||
func main() {
|
||||
auth := smtp.PlainAuth(
|
||||
@ -17,10 +17,12 @@ func main() {
|
||||
auth,
|
||||
"mark+sent@heroku.com",
|
||||
[]string{"mark@heroku.com"},
|
||||
[]byte("The Subject\r\n\r\nThe Body"),
|
||||
[]byte("nThe body."),
|
||||
)
|
||||
if err != nil { panic(err) }
|
||||
}
|
||||
|
||||
// missing subject, cc, bcc, attachements, plain/multi-type emails
|
||||
// https://github.com/mtoader/google-go-lang-idea-plugin/issues/112
|
||||
// todo: missing subject, cc, bcc
|
||||
// todo: attachements
|
||||
// todo: plain/multi-type emails
|
||||
// todo: https://github.com/mtoader/google-go-lang-idea-plugin/issues/112
|
@ -1,6 +1,9 @@
|
||||
// ## Enumerable
|
||||
|
||||
package main
|
||||
|
||||
import ("fmt"; "strings")
|
||||
import "strings"
|
||||
import "fmt"
|
||||
|
||||
func Index(elems []string, val string) int {
|
||||
for i, v := range elems {
|
@ -38,12 +38,11 @@ buffering
|
||||
directions
|
||||
synchronization
|
||||
select
|
||||
timeout
|
||||
string-fns
|
||||
timeouts
|
||||
string-functions
|
||||
bytes
|
||||
command-line-args
|
||||
command-line-arguments
|
||||
burstable-rate-limiting
|
||||
dns
|
||||
elapsed
|
||||
email
|
||||
enumerable
|
||||
|
Loading…
x
Reference in New Issue
Block a user