commit
d3c282497e
@ -39,7 +39,7 @@ func main() {
|
||||
|
||||
// Here we'll just dump out the parsed options and
|
||||
// any trailing positional arguments. Note that we
|
||||
// need to dereference the points with e.g. `*wordPtr`
|
||||
// need to dereference the pointers with e.g. `*wordPtr`
|
||||
// to get the actual option values.
|
||||
fmt.Println("word:", *wordPtr)
|
||||
fmt.Println("numb:", *numbPtr)
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Running the program shows that we pick up the value
|
||||
# value for `FOO` that we set in the program, but that
|
||||
# for `FOO` that we set in the program, but that
|
||||
# `BAR` is empty.
|
||||
$ go run environment-variables.go
|
||||
FOO: 1
|
||||
|
@ -36,7 +36,7 @@ func main() {
|
||||
// environment.
|
||||
env := os.Environ()
|
||||
|
||||
// Here's the actual `os.Exec` call. If this call is
|
||||
// Here's the actual `syscall.Exec` call. If this call is
|
||||
// successful, the execution of our process will end
|
||||
// here and be replaced by the `/bin/ls -a -l -h`
|
||||
// process. If there is an error we'll get a return
|
||||
|
@ -32,4 +32,4 @@ func main() {
|
||||
}
|
||||
|
||||
// Note that you don't need parentheses around conditions
|
||||
// in Go, but that the brackets are required.
|
||||
// in Go, but that the braces are required.
|
||||
|
@ -26,7 +26,7 @@ func main() {
|
||||
// This finds the match for the regexp.
|
||||
fmt.Println(r.FindString("peach punch"))
|
||||
|
||||
// The also finds the first match but returns the
|
||||
// This also finds the first match but returns the
|
||||
// start and end indexes for the match instead of the
|
||||
// matching text.
|
||||
fmt.Println(r.FindStringIndex("peach punch"))
|
||||
|
@ -63,7 +63,7 @@ func main() {
|
||||
// To double-quote strings as in Go source, use `%q`.
|
||||
fmt.Printf("%q\n", "\"string\"")
|
||||
|
||||
// As with integers as seen earlier, `%x` renders
|
||||
// As with integers seen earlier, `%x` renders
|
||||
// the string in base-16, with two output characters
|
||||
// per byte of input.
|
||||
fmt.Printf("%x\n", "hex this")
|
||||
|
@ -21,7 +21,7 @@ func main() {
|
||||
"2012-11-01T22:08:41+00:00")
|
||||
p(t1)
|
||||
|
||||
// `Format` and `Parse` uses example-based layouts. Usually
|
||||
// `Format` and `Parse` use example-based layouts. Usually
|
||||
// you'll use a constant from `time` for these layouts, but
|
||||
// you can also supply custom layouts. Layouts must use the
|
||||
// reference time `Mon Jan 2 15:04:05 MST 2006` to show the
|
||||
|
Loading…
x
Reference in New Issue
Block a user