I've the following code and I need to get the values like val1 and val2 and arg1 and arg2 and print it, I've tried many ways, is it possible ?
package main
import (
"flag"
"fmt"
"strings"
)
func main() {
args := strings.Fields("-loc .env -names val1 val2 -tags arg1 arg2")
FlagSet := flag.NewFlagSet("FlagSet", flag.ContinueOnError)
loc := FlagSet.String("loc", "", "")
name := FlagSet.String("names", "", "")
tags := FlagSet.String("tags", "", "")
FlagSet.Parse(args)
fmt.Printf("location: %s \n", *loc)
fmt.Printf("name: %s \n", *name)
fmt.Printf("tags: %s \n", *tags)
}