I'm trying to parse a form post that may be empty and if it is I will change the variable. Trying to use *string
type. The problem I'm having is it dosen't convert for the dashUrl
but does for the start_time
package main
import (
"encoding/base64"
"strconv"
"github.com/gocraft/web"
)
type YoutubeContext struct {
StartTime *float64 `json:"start_time"`
DashUrl *string `json:"dash_url"`
}
func (c *YoutubeContext) SetYoutubeContext(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc) {
if f, err := strconv.ParseFloat(req.FormValue("start_time"), 64); err == nil {
c.StartTime = &f
}
if dashUrl, dashUrlDecodeErr := base64.StdEncoding.DecodeString(req.FormValue("dash_url")); dashUrlDecodeErr == nil {
c.DashUrl = &dashUrl
}
}
func main() {
}
the error it shows is this
./test.go:19: cannot use &dashUrl (type *[]byte) as type *string in assignment