Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help getting started with goji #8

Closed
theirf opened this issue Apr 23, 2014 · 7 comments
Closed

help getting started with goji #8

theirf opened this issue Apr 23, 2014 · 7 comments

Comments

@theirf
Copy link

theirf commented Apr 23, 2014

Apologies if I am being a noob / novice, but I am just getting started with Go.

I'm trying to run the sample programme and I am getting an error.

Here is the contents of hello.go:

package main

import (
        "fmt"
        "net/http"

        "github.com/zenazn/goji"
        "github.com/zenazn/goji/web"
)

func hello(c web.C, w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "Hello, %s!", c.URLParams["name"])
}

func main() {
        goji.Get("/hello/:name", hello)
        goji.Serve()
}

hello.go:7:9: cannot find package "github.com/zenazn/goji" in any of:
/usr/local/go/src/pkg/github.com/zenazn/goji (from $GOROOT)
/Users/Irfan/Projects/Go/src/github.com/zenazn/goji (from $GOPATH)
hello.go:8:9: cannot find package "github.com/zenazn/goji/web" in any of:
/usr/local/go/src/pkg/github.com/zenazn/goji/web (from $GOROOT)
/Users/Irfan/Projects/Go/src/github.com/zenazn/goji/web (from $GOPATH)

What am I doing wrong?

@zenazn
Copy link
Owner

zenazn commented Apr 23, 2014

Did you run go get github.com/zenazn/goji?

@theirf
Copy link
Author

theirf commented Apr 23, 2014

Oh, no I didn't!

I'm so sorry. I was too excited about Goji.

Wait, I ran it. Now it is running successfully, saying Starting Goji on
[::]:8000 in the terminal, but that's it. I go to localhost:8000 and
nothing is there.

On 23 April 2014 18:42, Carl Jackson notifications@github.com wrote:

Did you run go get github.com/zenazn/goji?


Reply to this email directly or view it on GitHubhttps://github.com//issues/8#issuecomment-41223705
.

facebook.com/irfan.profile
google.com/+irfanmir
@theirf

@hoopsho
Copy link

hoopsho commented Apr 24, 2014

Because you are specifying in your routes that goji is to match requests on the following URL:

goji.Get("/hello/:name", hello)

You would want to specify that url in your browser. So for your example:

http://localhost:8000/hello/theirf

@theirf
Copy link
Author

theirf commented Apr 24, 2014

oh, beautiful! What I'd like to do is have a form and then on submit, sends what is in the textField to go and then print hello, name on the confirmation page.

Can someone help me with that?

@vasylnakvasiuk
Copy link

@theirf it's not an issue related to goji code and project.

@theirf
Copy link
Author

theirf commented Apr 24, 2014

True, but I figured the best place to get help with how to use goji would
be here.
On Apr 24, 2014 4:40 AM, "Vasyl Nakvasiuk" notifications@github.com wrote:

@theirf https://github.com/theirf it's not an issue related to gojicode and project.


Reply to this email directly or view it on GitHubhttps://github.com//issues/8#issuecomment-41256495
.

@zenazn
Copy link
Owner

zenazn commented Apr 25, 2014

@theirf — for my own sanity, I'd actually like to keep the issues page on Github focused on issues with Goji itself. I'll look into starting a mailing list or IRC channel some time this weekend.

As for your original question, this can be accomplished using an HTML form with an "action" attribute (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) that POSTs to another route on your site. You can then dig the form data from Go's http.Request object. There are many tutorials online covering POSTing data, and while I doubt any will be Goji-specific, I'm sure you'll find that the principles and ideas—as well as all of the HTML—translate well.

@zenazn zenazn closed this as completed Apr 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants