I am fairly new to Go, and I am trying to make a few apps for GAE. I couldn't find anyone with the same problem as me so I thought I would ask here!
Basically, I am creating a program that will take a random url from an array and redirect the user.
The problem that arises is that on every computer I try it on, it will send a different video, but it will always send the same video to that person.
If anyone has any insight into this it would be greatly appreciated!
package randvid
import (
"net/http"
"math/rand"
"time"
)
func RandLink() string{
VideoList := []string{
...
}
r := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
vid := r.Intn(len(VideoList)) + 1;
return VideoList[vid]
}
func redirectHandler(path string) func(http.ResponseWriter, *http.Request) {
return func (w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, path, http.StatusMovedPermanently)
}
}
func init() {
http.HandleFunc("/", redirectHandler(RandLink()))
}