I created a small Go application with the https://github.com/spf13/cobra library.
I created a new flag, -t
or --token
, and when I pass this argument I want the application to print it.
This is what I did:
func init() {
fmt.Println("[*] Inside init()")
var token string
rootCmd.PersistentFlags().StringVarP(&token, "token", "t", "", "Service account Token (JWT) to insert")
fmt.Println(token)
}
But it doesn't print it when I run the application like that:
.\consoleplay.exe --token "hello.token"
How can I print the value of the flags.