go-sh
go-sh copied to clipboard
Dont support uint in arguments
Hello! i tried use this:
package main
import (
"github.com/codeskyblue/go-sh"
"log"
"fmt"
)
func main() {
port := uint(1)
session := sh.NewSession()
session.ShowCMD = true
out, err := session.Command("/Users/Ivan/Downloads/redis-3.2.3/src/redis-server", "--port", port).Output()
if err != nil {
log.Fatal("ERROR: ", err)
}
fmt.Println("output is", string(out))
}
And have result:
/usr/local/go/bin/go run /Users/Ivan/Documents/GolangSpace/src/examples/test.go
[golang-sh]$ /Users/Ivan/Downloads/redis-3.2.3/src/redis-server --port
*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 2
>>> 'port'
Bad directive or wrong number of arguments
2016/09/09 15:55:25 ERROR: exit status 1
exit status 1
This means redis-server not support --port argument.
@codeskyblue No.
Please look print command:
[golang-sh]$ /Users/Ivan/Downloads/redis-3.2.3/src/redis-server --port"
But in code:
out, err := session.Command("/Users/Ivan/Downloads/redis-3.2.3/src/redis-server", "--port", port).Output()
For my project, i use this fix (just convert uint to string):
_, err := session.Command(REDIS_EXEC_PATH, "--port", fmt.Sprint(redis.Port)).Output()
And its work.
Yep, I remember it is because the inject lib, so only string is working.
@codeskyblue Okay, maybe allow only []string? Or convert by sprit?
sorry I dont very understand?
Maybe need to write another lib
I met this too, Command() doesn't non-string type, will discard it