We can use the predefined url.URL struct in net/url package as type of the
arguments that are expected. Nevertheless, there is not predefined function
in flag package that instaciate that kind of flag for us.

Forthunately, it provides an easy way to extend that by using flag.Var function.
It creates a flag for any type that obey flag.Value interface:

type Value interface {
String()
Set(string) error
}

Lets declare the type UrlFlag:

type UrlFlag struct {
urls []*url.URL
}

Then you should define String() function that converts this struct as a string:

func (arr *UrlFlag) String() string {
return fmt.Sprint(arr.urls)
}

The Set(string) is called by flag.Parse
function. It initializes this flag from command line arguments.
In our case, we will expect comma-separated list of values: