nativehttp

Simple interface to the native http client
Log | Files | Refs | README | LICENSE

commit 777550d534f2443cd95ecc3d2423ea7563d80248
parent af19b49425a7d768a68d26da1e56f698015e6b01
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date:   Tue, 13 Feb 2024 10:24:00 +0800

example/get: avoid flag package

It's quite a hefty package and we don't need sophisticated flag handling.

Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>

Diffstat:
Mexample/get/main.go | 15++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/example/get/main.go b/example/get/main.go @@ -2,7 +2,6 @@ package main import ( "errors" - "flag" "io" "os" @@ -11,14 +10,16 @@ import ( func main() { var ( - uri string - file string + uri string = "https://www.example.com" + file string = "file.html" ) - flag.StringVar(&uri, "uri", "https://www.example.com", "uri to GET") - flag.StringVar(&file, "o", "file.html", "output file") - - flag.Parse() + if len(os.Args) > 1 { + uri = os.Args[1] + } + if len(os.Args) > 2 { + file = os.Args[2] + } if err := downloadFile(uri, file); err != nil { print("error: %v\n", err)