Golang单元测试python函数

I have an API handler in Golang that calls a python function. How can I mock the response from the python function to avoid dependence of that function running correctly to test the Golang function?

You could wrap your function into a new moc function:

func CallPythonFunctionMoc() Result {
    var res Result
    var err error
    res, err = CallPythonFunction()
    if err != nil {
        res = "Moc value"
    }
    return res

Edit:

If you do NOT actually want to call the python function just return the moc-value:

func CallPythonFunctionMoc() Result {
    res := "Moc value"
    return res