This is a port of the parserargs.js project to Go.
What about parsing arguments allowing quotes in them? But beware that this library will not parse flags (-- and -), flags will be returned as simple strings.
go get -u github.com/txgruppi/parseargs-go
package main
import (
"fmt"
"log"
"github.com/txgruppi/parseargs-go"
)
func main() {
setInRedis := `set name "Put your name here"`
parsed, err := parseargs.Parse(setInRedis)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%#v\n", parsed) // []string{"set", "name", "Put your name here"}
}
go get -u -t github.com/txgruppi/parseargs-go
cd $GOPATH/src/github.com/txgruppi/parseargs-go
go test ./...
MIT