2
0
mirror of https://github.com/miguelmota/cointop synced 2024-11-05 00:00:14 +00:00
cointop/vendor/github.com/anmitsu/go-shlex
2020-07-26 13:40:59 -07:00
..
.gitignore Add SSH server 2020-07-26 13:40:59 -07:00
go.mod Add SSH server 2020-07-26 13:40:59 -07:00
LICENSE Add SSH server 2020-07-26 13:40:59 -07:00
README.md Add SSH server 2020-07-26 13:40:59 -07:00
shlex.go Add SSH server 2020-07-26 13:40:59 -07:00

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

Documentation

http://godoc.org/github.com/anmitsu/go-shlex