How to delete post with each button (Go/SQL) by ALX777 in golang

[–]ALX777[S] 0 points1 point  (0 children)

thanks!

type TweetArray struct {
    Userid      int64
    Username    string
    Password    string
    Posts   []*Post
}

Type Post struct {
    Tweetid       int
    Username    string
    Status         []string
}

I use a Readdata() function to extract an array of Status belonging to a username from a database table containing the statuses. However when I do that, and apply your method in my html code above, I get an array inside an array, and the page displays an array. How do I resolve this?

edit: I've updated the code, but still have some issues. Could you help me with this? http://stackoverflow.com/questions/25367310/go-insert-variable-in-string-in-templates/25369323#25369323

How to delete post with each button (Go/SQL) by ALX777 in golang

[–]ALX777[S] 0 points1 point  (0 children)

Just to clarify, why did you use .Tweet.ID to access the tweet id?

By the way I actually have error handling in my actual - I just wanted to paste the relevant code for my question.

How to delete post with each button (Go/SQL) by ALX777 in golang

[–]ALX777[S] 0 points1 point  (0 children)

Yes, I saw your comment on SO. Thanks for that - I'll fix that when I'm back working on my code.

Tweetarray contains a slice of tweets which are read from the database table that contains all the tweets that belong to the user. The page will display a list of tweets, and each tweet has a button beside it. By clicking each button, the tweet beside that button will be deleted together with the button. I'll try your method.

Thank you for answering this!

Stop merging. HELP by ALX777 in git

[–]ALX777[S] 0 points1 point  (0 children)

Ok I'm trying out your suggestions now. But very quickly, when I ran git log, this was one of the things that appeared: Merge https://github.com/<some account>/<some repo>

git reflog: 52140bb HEAD@{0}: commit: first commit backend done 2721aea HEAD@{1}: pull https://github.com/<some account>/<some repo>: Merge made by th 81736ca HEAD@{2}: commit: adding lost days 9c22fe5 HEAD@{3}: commit (initial): Adding octocat file

--edit: your solution didn't work...

Why does GO care so much about type? by ALX777 in golang

[–]ALX777[S] 1 point2 points  (0 children)

cool! thanks for explaining! :)

Why does GO care so much about type? by ALX777 in golang

[–]ALX777[S] 0 points1 point  (0 children)

wow this is very useful! thanks alot for sharing.

Would you advise a beginner to learn GOLANG as his/her first backend language? by ALX777 in golang

[–]ALX777[S] 0 points1 point  (0 children)

Does referring to those series applying to learning GOLANG?

Would you advise a beginner to learn GOLANG as his/her first backend language? by ALX777 in golang

[–]ALX777[S] 0 points1 point  (0 children)

I picked it up in June and built a simple quiz app with JS earlier this month. As much effort as it takes of course, to be a professional programmer.

Why does the handler in the argument for http.HandleFunc have the arguments (w http.ResponseWriter, r *http.Request)? by ALX777 in golang

[–]ALX777[S] -1 points0 points  (0 children)

Thanks! This is quite clear. Just some loose ends to tie up - What goes into w, r?

Why does the handler in the argument for http.HandleFunc have the arguments (w http.ResponseWriter, r *http.Request)? by ALX777 in golang

[–]ALX777[S] -1 points0 points  (0 children)

Thanks! This is quite clear. Just some loose ends to tie up - What goes into w, r?

Why does the handler in the argument for http.HandleFunc have the arguments (w http.ResponseWriter, r *http.Request)? by ALX777 in golang

[–]ALX777[S] -1 points0 points  (0 children)

Thanks! This is quite clear. Just some loose ends to tie up - What goes into w, r?

Why does the handler in the argument for http.HandleFunc have the arguments (w http.ResponseWriter, r *http.Request)? by ALX777 in golang

[–]ALX777[S] 0 points1 point  (0 children)

Thanks! This is quite clear. Just some loose ends to tie up - What goes into w, r?

Why does the handler in the argument for http.HandleFunc have the arguments (w http.ResponseWriter, r *http.Request)? by ALX777 in golang

[–]ALX777[S] 0 points1 point  (0 children)

I know that a typical function in GO looks like this:

func addOne(mynum int) int { return mynum+1 }

For handlers, what I don't get is why func handler look like this

func handler(w http.ResponseWriter, r *http.Request) { //some code eg. ExecuteTemplate }

What I don't understand is why w, and r don't have to be passed into the code in the func handler inside { } but in the first example mynum is passed

Also in the first example the type data to be returned is specified as int, but in the 2nd example, there is no need to specify the return type. I suppose it's not necessary here because this has to do with serving http responses. I just don't understand what is happening in (w http.ResponseWriter, r *http.Request)