Golang如何获取完整的文件路径

I been searching around and can not find a way to get the full file path in Go . I have a regular html form and then I try to get all the information in the backend

<form method="post" enctype="multipart/form-data"  action="/uploads">
    <p><input type="file" name="my file" id="my file"></p>
    <p>
        <input type="submit" value="Submit">
    </p>

func upload() {

    f,h,err := r.FormFile("my file")
    if err != nil {
        log.Println(err)
        http.Error(w,"Error Uploading",http.StatusInternalServerError)
        return
    }
    defer  f.Close()
   println(h.Filename)
    }

// This gets me the name of the file, I would like the full path of it

I have tried file path.dir() but that does not do anything

As far as I know, you cannot get the filepath form the f value in your code. Because the file data is not stored in disk yet.

And you want to store the file to a path, you can do it this way.

f,h,err := r.FormFile("myfile")
if err != nil{
    log.Println("err: ",err)
    http.Error(w,"Error Uploading",http.StatusInternalServerError)
    return
}
defer f.Close()
fmt.Println("filename: ",h.Filename)


bytes, err := ioutil.ReadAll(f)
if err != nil { 
    fmt.Println(err) 
} 
filepath := "./aa" //set your filename and filepath
err = ioutil.WriteFile("aa", bytes, 0777) 
if err != nil { 
    fmt.Println(err) 
}