Go use of exec.Command on windows for noverify

前端 未结 1 1449
野的像风
野的像风 2021-01-25 01:14

I want to use VKCOM/noverify to analyse code. Calling it from the command-line (windows dos shell) using this command works

 noverify.exe -exclude-checks arraySyn         


        
相关标签:
1条回答
  • 2021-01-25 01:24

    There are multible options to pass arguments to exec.Command:

    You can use multible strings as arguments:

    cmd := exec.Command("your-command", "arg1", "arg2")
    

    If you have a slice of arguments, you can use the spread operator

    args := []string{"-exclude-checks", "arraySyntax,phpdocLint", "-output", "result.txt", "your-path"}
    cmd := exec.Command("your-command", args...)
    

    To question two: In your code

    options := " -exclude-checks arraySyntax, PHPDoc"
    pathToCode := "C:\\Dev\\PHP\\ResourceSpace_9_0_13357\\include"
    
    args := []string{options, pathToCode}
    

    you're passing two options to the external program. If you wrote the same on the command line, you pass

    your-command.exe " -exclude-checks arraySyntax, PHPDoc" "your-path"
    

    This doesn't work, and is also the reason your program doesn't work.

    In short, whereever you put a space between in a command, you need to have a separate argument to exec.Command. The example also does this.

    0 讨论(0)
提交回复
热议问题