diff options
author | Alex Mayer <amayer5125@gmail.com> | 2019-06-20 00:33:10 -0400 |
---|---|---|
committer | Alex Mayer <amayer5125@gmail.com> | 2019-06-20 00:33:10 -0400 |
commit | 4030ecb67d99ff35610b3b830dfebf9569201434 (patch) | |
tree | ff921f87005142b8de89470fc987011c68bc95b3 | |
parent | ab116f62282cb201ba2903d24bbce9eb03ee3e38 (diff) | |
download | gh_authkey_checker-4030ecb67d99ff35610b3b830dfebf9569201434.tar gh_authkey_checker-4030ecb67d99ff35610b3b830dfebf9569201434.tar.gz gh_authkey_checker-4030ecb67d99ff35610b3b830dfebf9569201434.tar.bz2 gh_authkey_checker-4030ecb67d99ff35610b3b830dfebf9569201434.tar.lz gh_authkey_checker-4030ecb67d99ff35610b3b830dfebf9569201434.tar.xz gh_authkey_checker-4030ecb67d99ff35610b3b830dfebf9569201434.tar.zst gh_authkey_checker-4030ecb67d99ff35610b3b830dfebf9569201434.zip |
Check Args In Main Function
Remove parseArgs function
-rw-r--r-- | main.go | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -8,15 +8,6 @@ import ( "os" ) -func parseArgs() (string, error) { - // We can only accept one argument - if len(os.Args) != 2 { - return "", fmt.Errorf("Usage: gh_authkey_checker <username>") - } - - return os.Args[1], nil -} - func fetchKeys(username string) (string, error) { url := fmt.Sprintf("https://github.com/%s.keys", username) resp, err := http.Get(url) @@ -42,11 +33,14 @@ func fetchKeys(username string) (string, error) { } func main() { - username, err := parseArgs() - if err != nil { - log.Fatal(err) + // Ensure we have the correct number of arguments + if len(os.Args) != 2 { + fmt.Println("Usage: gh_authkey_checker <username>") + os.Exit(1) } + username := os.Args[1] + log.Printf("Fetching keys for user %s", username) keys, err := fetchKeys(username) if err != nil { |