CODE: add an ARGV processing example

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-09-01 14:55:34 -05:00
parent 21a050c953
commit 478750e2dd
2 changed files with 27 additions and 0 deletions

View File

@ -32,6 +32,7 @@ build:
cd example-ssh; go install # scp example cd example-ssh; go install # scp example
# golang things # golang things
cd example-flag; go install # process argv
cd example-pprof; go install # dump out go process internals cd example-pprof; go install # dump out go process internals
cd example-bench-fast-timer; go install # time golang channels cd example-bench-fast-timer; go install # time golang channels
cd example-bench-readWriteOps; go install # cd example-bench-readWriteOps; go install #

26
example-flag/flag.go Normal file
View File

@ -0,0 +1,26 @@
package main
import (
"flag"
"fmt"
"time"
"github.com/google/goterm/term"
)
const (
timeout = 10 * time.Minute
)
var (
addr = flag.String("address", "", "address of telnet server")
user = flag.String("user", "user", "username to use")
pass1 = flag.String("pass1", "pass1", "password to use")
pass2 = flag.String("pass2", "pass2", "alternate password to use")
)
func main() {
flag.Parse()
fmt.Println(term.Bluef("flag Example"))
fmt.Println("addr=",addr)
}