Golang,exec和back ticks shell命令

I am trying to use os.exec (https://nathanleclaire.com/blog/2014/12/29/shelled-out-commands-in-golang/) with a command like:

value=`something`; echo $value

But it appears to the back ticks are messing with the command of the strings.Split I do.

If I use

something
it works

How can I use the back ticks? Do I have to find out another way to write my command?

Thanks

Go executes these commands a way that you can't use shell things, because it creates a new process. So you should create a new shell process, for example:

package main

import (
    "os"
    "os/exec"
)

func main() {
    cmd := exec.Command("sh", "-c", "value=`ls`; echo $value")
    cmd.Stdout = os.Stdout
    err := cmd.Run()
    if err != nil {
        panic(err)
    }

}

Let me know if it's not what you want!