mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-29 22:35:26 +03:00
…
|
||
---|---|---|
.. | ||
.gitignore | ||
go.mod | ||
LICENSE | ||
README.md | ||
shlex.go |
go-shlex
go-shlex is a library to make a lexical analyzer like Unix shell for Go.
Install
go get -u "github.com/anmitsu/go-shlex"
Usage
package main
import (
"fmt"
"log"
"github.com/anmitsu/go-shlex"
)
func main() {
cmd := `cp -Rdp "file name" 'file name2' dir\ name`
words, err := shlex.Split(cmd, true)
if err != nil {
log.Fatal(err)
}
for _, w := range words {
fmt.Println(w)
}
}
output
cp
-Rdp
file name
file name2
dir name