aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Mayer <amayer5125@gmail.com>2019-06-20 00:33:10 -0400
committerAlex Mayer <amayer5125@gmail.com>2019-06-20 00:33:10 -0400
commit4030ecb67d99ff35610b3b830dfebf9569201434 (patch)
treeff921f87005142b8de89470fc987011c68bc95b3
parentab116f62282cb201ba2903d24bbce9eb03ee3e38 (diff)
downloadgh_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.go18
1 files changed, 6 insertions, 12 deletions
diff --git a/main.go b/main.go
index f214a09..32ddf6c 100644
--- a/main.go
+++ b/main.go
@@ -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 {