Wednesday, November 29, 2017

visual code add quick debug profile to go lang project

visual code add quick debug profile to go lang project

how to it:
in vs code > vscode/launch.json file, add below code:    (or used left debug panel > add profile)

    {
        "name": "xg",
        "type": "go",
        "request": "launch",
        "mode": "debug",
        "remotePath": "",
        "port": 8086,
        "host": "127.0.0.1",
        "program": "${env:GOPATH}/src/sx98/xg/main.go",
        "cwd": "${env:GOPATH}/src/sx98/xg/",
        "env": {},
        "args": [],
        "showLog": true
    }

Then, in left debug panel, choose "xg", now can debug quickly. From now, no need locate to "src/sx98/xg/main.go" and press F5.


Tuesday, November 28, 2017

go lang, cannot use columns (type []string) as type string in argument to string

i want to used type []string to ...string when call some function with variable parameters. in go lang code.

write below code:

func f(p ...string){
    // ...
}

correct code:
var p []string
f(p...)

error code:
var p []string
f(p)

it said:
cannot use columns (type []string) as type string in argument to string