Check if Flag Was Provided in Go

Use the flag.Visit()

Description:
Visit visits the command-line flags in lexicographical order, calling fn for each. It visits only those flags that have been set.

use:

func isFlagPassed(name string) bool {
    found := false
    flag.Visit(func(f *flag.Flag) {
        if f.Name == name {
            found = true
        }
    })
    return found
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)