improve gcmd.Scan*

This commit is contained in:
John
2019-12-14 22:48:53 +08:00
parent e33230a88f
commit 4996755f11
2 changed files with 2 additions and 28 deletions

View File

@ -13,7 +13,7 @@ import "fmt"
func Scan(info ...interface{}) string {
var s string
fmt.Print(info...)
fmt.Scan(&s)
fmt.Scanln(&s)
return s
}
@ -21,6 +21,6 @@ func Scan(info ...interface{}) string {
func Scanf(format string, info ...interface{}) string {
var s string
fmt.Printf(format, info...)
fmt.Scan(&s)
fmt.Scanln(&s)
return s
}

View File

@ -1,26 +0,0 @@
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gproc
import (
"github.com/gogf/gf/test/gtest"
"testing"
)
func Test_parseCommand(t *testing.T) {
gtest.Case(t, func() {
commandMap := map[string]interface{}{
`cmd`: []string{`cmd`},
`cmd /c`: []string{`cmd`, `/c`},
`cmd /c go build`: []string{`cmd`, `/c`, `go`, `build`},
`cmd /c go build -ldflags "-X 'a=123' -X 'b=456'" test.go`: []string{`cmd`, `/c`, `go`, `build`, `-ldflags`, `"-X 'a=123' -X 'b=456'"`, `test.go`},
}
for k, v := range commandMap {
gtest.Assert(parseCommand(k), v)
}
})
}