I created a simple web application using Google App Engine and golang. in the code below, I use fmt.Println twice to print something for debugging purposes. I have no problem running the application. everything works except nothing is printed on the terminal.
func HomeHandler(w http.ResponseWriter, r *http.Request) { c := appengine.NewContext(r) q := datastore.NewQuery("Post").Ancestor(goblogKey(c)).Order("-CreatedOn").Limit(10) //posts := make([]entity.Post, 0, 10) var posts []entity.Post if _, err := q.GetAll(c, &posts); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } fmt.Println(string(len(posts)) + "...........") postList := []dto.Post{} for _, val := range posts { newpost := dto.Post{ Post: val, BodyHTML: template.HTML(val.Body), } fmt.Println(val.Title) postList = append(postList, newpost) } page := dto.PageData{Title: "Home", Posts: postList} templates.ExecuteTemplate(w, "index", page) }
source share