ValoraChen
ValoraChen

Reputation: 93

Unable to properly read CLI flag

As stated in the title, I'm not able to properly print -e flag value[email protected].

This is my code so far:

package main

import (
    "flag"
    "fmt"
)

func main() {
    var email string
    flag.StringVar(&email, "e", "", "email")
    flag.Parse()
    fmt.Println(email)
}

After running with go run test.go [email protected] I get test@test output.

How do I get "[email protected]"?

Upvotes: 1

Views: 65

Answers (1)

Grzegorz Żur
Grzegorz Żur

Reputation: 49181

Run it in single quotation marks so the shell leave it as it is

go run test.go '[email protected]'

Upvotes: 2

Related Questions