From 478750e2ddb91b886ef7950873059552c9c063f4 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 1 Sep 2021 14:55:34 -0500 Subject: [PATCH] CODE: add an ARGV processing example Signed-off-by: Jeff Carr --- Makefile | 1 + example-flag/flag.go | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 example-flag/flag.go diff --git a/Makefile b/Makefile index cc629d6..a414fff 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ build: cd example-ssh; go install # scp example # golang things + cd example-flag; go install # process argv cd example-pprof; go install # dump out go process internals cd example-bench-fast-timer; go install # time golang channels cd example-bench-readWriteOps; go install # diff --git a/example-flag/flag.go b/example-flag/flag.go new file mode 100644 index 0000000..56d65ef --- /dev/null +++ b/example-flag/flag.go @@ -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) +}