I'm trying to print the command line arguments that I'm passing to my program, but the quotes (") are disappearing.
e.g:
package main
import (
"fmt"
"os"
"strings"
)
func main() {
fmt.Println(strings.join(os.Args[1:], " "))
}
Then run using go run test.go "status"
- This should print "status"
, but it's printing status
.
This strictly depends on the shell executing the program and not Go itself. If you are using bash for example, try executing the program while escaping the double quotes. Like so
go run test.go '"status"'
# OR
go run test.go \"status\"